editor: delete
This commit is contained in:
parent
9908406623
commit
139e75786b
2 changed files with 38 additions and 1 deletions
|
@ -55,6 +55,7 @@ Edit the level `N: u32` with the command `bevyjam <N> e`.
|
||||||
|
|
||||||
* **Select**: left click to select, click in void to deselect, CTRL+click to select many, CTRL+A to select all
|
* **Select**: left click to select, click in void to deselect, CTRL+click to select many, CTRL+A to select all
|
||||||
* **Move selection**: arrows to move one step, Shift+arrows to move continuously
|
* **Move selection**: arrows to move one step, Shift+arrows to move continuously
|
||||||
|
* **Delete selection**: delete
|
||||||
* **Move camera**: CTRL+arrows
|
* **Move camera**: CTRL+arrows
|
||||||
* **Save**: CTRL+S
|
* **Save**: CTRL+S
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,8 @@ impl Plugin for EditorPlugin {
|
||||||
SystemSet::on_update(AppState::Editor)
|
SystemSet::on_update(AppState::Editor)
|
||||||
.with_system(move_system)
|
.with_system(move_system)
|
||||||
.with_system(input_control_system)
|
.with_system(input_control_system)
|
||||||
.with_system(follow_ends_system),
|
.with_system(follow_ends_system)
|
||||||
|
.with_system(remove_system),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,6 +62,9 @@ struct RotatingFilterAngle(f32);
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
struct AbsorbingFilterColor(Color);
|
struct AbsorbingFilterColor(Color);
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
struct Removable;
|
||||||
|
|
||||||
// Bundles
|
// Bundles
|
||||||
|
|
||||||
#[derive(Bundle)]
|
#[derive(Bundle)]
|
||||||
|
@ -69,6 +73,9 @@ struct PlatformBundle {
|
||||||
mesh: ColorMesh2dBundle,
|
mesh: ColorMesh2dBundle,
|
||||||
size: Size,
|
size: Size,
|
||||||
platform: Platform,
|
platform: Platform,
|
||||||
|
#[bundle]
|
||||||
|
pickable: PickableBundle,
|
||||||
|
removable: Removable,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Bundle)]
|
#[derive(Bundle)]
|
||||||
|
@ -89,6 +96,7 @@ struct CharacterBundle {
|
||||||
#[bundle]
|
#[bundle]
|
||||||
pickable: PickableBundle,
|
pickable: PickableBundle,
|
||||||
draggable: Draggable,
|
draggable: Draggable,
|
||||||
|
removable: Removable,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Bundle)]
|
#[derive(Bundle)]
|
||||||
|
@ -97,6 +105,9 @@ struct AbsorbingFilterBundle {
|
||||||
mesh: ColorMesh2dBundle,
|
mesh: ColorMesh2dBundle,
|
||||||
size: Size,
|
size: Size,
|
||||||
color: AbsorbingFilterColor,
|
color: AbsorbingFilterColor,
|
||||||
|
#[bundle]
|
||||||
|
pickable: PickableBundle,
|
||||||
|
removable: Removable,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Bundle)]
|
#[derive(Bundle)]
|
||||||
|
@ -107,6 +118,7 @@ struct RotatingFilterBundle {
|
||||||
#[bundle]
|
#[bundle]
|
||||||
pickable: PickableBundle,
|
pickable: PickableBundle,
|
||||||
draggable: Draggable,
|
draggable: Draggable,
|
||||||
|
removable: Removable,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
|
@ -129,6 +141,8 @@ fn spawn_platform(
|
||||||
},
|
},
|
||||||
size: Size(size),
|
size: Size(size),
|
||||||
platform: Platform,
|
platform: Platform,
|
||||||
|
pickable: PickableBundle::default(),
|
||||||
|
removable: Removable,
|
||||||
})
|
})
|
||||||
.id();
|
.id();
|
||||||
let ends = Ends(
|
let ends = Ends(
|
||||||
|
@ -207,6 +221,7 @@ fn spawn_character(
|
||||||
color: CharacterColor(color),
|
color: CharacterColor(color),
|
||||||
pickable: PickableBundle::default(),
|
pickable: PickableBundle::default(),
|
||||||
draggable: Draggable,
|
draggable: Draggable,
|
||||||
|
removable: Removable,
|
||||||
})
|
})
|
||||||
.with_children(|c| {
|
.with_children(|c| {
|
||||||
c.spawn_bundle(Text2dBundle {
|
c.spawn_bundle(Text2dBundle {
|
||||||
|
@ -245,6 +260,8 @@ fn spawn_absorbing_filter(
|
||||||
},
|
},
|
||||||
size: Size(size),
|
size: Size(size),
|
||||||
color: AbsorbingFilterColor(color),
|
color: AbsorbingFilterColor(color),
|
||||||
|
pickable: PickableBundle::default(),
|
||||||
|
removable: Removable,
|
||||||
})
|
})
|
||||||
.id();
|
.id();
|
||||||
let ends = Ends(
|
let ends = Ends(
|
||||||
|
@ -322,6 +339,7 @@ fn spawn_rotating_filter(
|
||||||
angle: RotatingFilterAngle(angle),
|
angle: RotatingFilterAngle(angle),
|
||||||
pickable: PickableBundle::default(),
|
pickable: PickableBundle::default(),
|
||||||
draggable: Draggable,
|
draggable: Draggable,
|
||||||
|
removable: Removable,
|
||||||
})
|
})
|
||||||
.with_children(|c| {
|
.with_children(|c| {
|
||||||
c.spawn_bundle(Text2dBundle {
|
c.spawn_bundle(Text2dBundle {
|
||||||
|
@ -584,6 +602,24 @@ fn move_system(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn remove_system(
|
||||||
|
mut commands: Commands,
|
||||||
|
keyboard_input: Res<Input<KeyCode>>,
|
||||||
|
mut removable_query: Query<(Entity, &Selection, Option<&Ends>), With<Removable>>,
|
||||||
|
) {
|
||||||
|
if keyboard_input.just_released(KeyCode::Delete) {
|
||||||
|
for (entity, selection, ends) in removable_query.iter_mut() {
|
||||||
|
if selection.selected() {
|
||||||
|
commands.entity(entity).despawn_recursive();
|
||||||
|
if let Some(ends) = ends {
|
||||||
|
commands.entity(ends.0).despawn_recursive();
|
||||||
|
commands.entity(ends.1).despawn_recursive();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn follow_ends_system(
|
fn follow_ends_system(
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
mut follower_query: Query<(&mut Transform, &mut Mesh2dHandle, &mut Size, &Ends)>,
|
mut follower_query: Query<(&mut Transform, &mut Mesh2dHandle, &mut Size, &Ends)>,
|
||||||
|
|
Loading…
Reference in a new issue