editor: add objects
This commit is contained in:
parent
139e75786b
commit
585b74bf72
2 changed files with 66 additions and 2 deletions
|
|
@ -23,7 +23,8 @@ impl Plugin for EditorPlugin {
|
|||
.with_system(move_system)
|
||||
.with_system(input_control_system)
|
||||
.with_system(follow_ends_system)
|
||||
.with_system(remove_system),
|
||||
.with_system(remove_system)
|
||||
.with_system(spawn_system),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -620,6 +621,68 @@ fn remove_system(
|
|||
}
|
||||
}
|
||||
|
||||
fn spawn_system(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||
asset_server: Res<AssetServer>,
|
||||
camera_query: Query<&Transform, With<Camera>>,
|
||||
keyboard_input: Res<Input<KeyCode>>,
|
||||
mut character_list: ResMut<CharacterList>,
|
||||
) {
|
||||
if keyboard_input.pressed(KeyCode::LControl)
|
||||
|| keyboard_input.pressed(KeyCode::RControl)
|
||||
|| keyboard_input.pressed(KeyCode::LAlt)
|
||||
|| keyboard_input.pressed(KeyCode::RAlt)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
let camera_pos = camera_query.single().translation;
|
||||
|
||||
if keyboard_input.just_released(KeyCode::P) {
|
||||
spawn_platform(
|
||||
&mut commands,
|
||||
&mut meshes,
|
||||
&mut materials,
|
||||
Transform::from_xyz(camera_pos.x, camera_pos.y, 0.),
|
||||
Vec2 { x: 96., y: 16. },
|
||||
);
|
||||
}
|
||||
if keyboard_input.just_released(KeyCode::C) {
|
||||
let index = character_list.0.len();
|
||||
character_list.0.push(spawn_character(
|
||||
&mut commands,
|
||||
&mut meshes,
|
||||
&mut materials,
|
||||
&asset_server,
|
||||
Transform::from_xyz(camera_pos.x, camera_pos.y, 0.),
|
||||
Color::RED,
|
||||
index,
|
||||
));
|
||||
}
|
||||
if keyboard_input.just_released(KeyCode::A) {
|
||||
spawn_absorbing_filter(
|
||||
&mut commands,
|
||||
&mut meshes,
|
||||
&mut materials,
|
||||
Transform::from_xyz(camera_pos.x, camera_pos.y, 0.),
|
||||
Vec2 { x: 16., y: 96. },
|
||||
Color::RED,
|
||||
);
|
||||
}
|
||||
if keyboard_input.just_released(KeyCode::R) {
|
||||
spawn_rotating_filter(
|
||||
&mut commands,
|
||||
&mut meshes,
|
||||
&mut materials,
|
||||
&asset_server,
|
||||
Transform::from_xyz(camera_pos.x, camera_pos.y, 0.),
|
||||
90.,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn follow_ends_system(
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut follower_query: Query<(&mut Transform, &mut Mesh2dHandle, &mut Size, &Ends)>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue