feat: editor paint undone
This commit is contained in:
parent
a3752a6496
commit
fb0e374f17
4 changed files with 144 additions and 13 deletions
|
|
@ -8,10 +8,10 @@ pub struct GameViewPlugin;
|
|||
|
||||
impl Plugin for GameViewPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(PreStartup, debug_setup_grid)
|
||||
app
|
||||
.init_resource::<CubeStages>()
|
||||
.init_resource::<TileMaterials>()
|
||||
.add_systems(Startup, setup_view_cubes)
|
||||
.add_systems(Startup, (setup_building_planes,setup_view_cubes))
|
||||
.add_systems(Update, update_cubes);
|
||||
}
|
||||
}
|
||||
|
|
@ -33,14 +33,31 @@ pub struct TileMaterials {
|
|||
pub source: Handle<StandardMaterial>,
|
||||
}
|
||||
|
||||
pub fn debug_setup_grid(mut grid: ResMut<Grid>) {
|
||||
use crate::grid::GridElement;
|
||||
let mut tool = grid.manipulate();
|
||||
tool.fill_xyz(5, 0, 1, 5, 0, 14, GridElement::Solid);
|
||||
//tool.fill_xyz(0, 0, 0, 4, 0, 15, GridElement::Water { amount: MAX_FLUID_AMOUNT });
|
||||
//tool.set_xyz(0, 0, 6, GridElement::Source { source_amount: MAX_FLUID_AMOUNT });
|
||||
tool.set_xyz(0, 8, 6, GridElement::Source { source_amount: MAX_FLUID_AMOUNT });
|
||||
//tool.set_xyz(15,0, 6, GridElement::Drain);
|
||||
pub fn setup_building_planes(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
grid: Res<Grid>
|
||||
) {
|
||||
let mut mesh: Mesh = (Cuboid::new(grid.size.x as f32, grid.size.y as f32, grid.size.z as f32).mesh()).into();
|
||||
let _ = mesh.invert_winding();
|
||||
|
||||
|
||||
let mesh_handle = meshes.add(mesh);
|
||||
let center = (grid.size.as_vec3() - Vec3::ONE)/2.;
|
||||
commands.spawn_scene(bsn!{
|
||||
Mesh3d(mesh_handle)
|
||||
Transform {
|
||||
translation: center
|
||||
}
|
||||
MeshMaterial3d<StandardMaterial>(asset_value(
|
||||
StandardMaterial {
|
||||
base_color: Color::WHITE,
|
||||
..default()
|
||||
}
|
||||
))
|
||||
Visibility::Visible
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
pub fn setup_view_cubes(
|
||||
|
|
@ -81,7 +98,7 @@ pub fn setup_view_cubes(
|
|||
commands.spawn_scene(
|
||||
cube(
|
||||
grid.deindexify(i as u32).as_vec3(),
|
||||
i as usize,
|
||||
i as usize,
|
||||
mesh.clone()
|
||||
)
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue