diff --git a/bevy_examples/Cargo.toml b/bevy_examples/Cargo.toml index 49d31a3..a2bdd6f 100644 --- a/bevy_examples/Cargo.toml +++ b/bevy_examples/Cargo.toml @@ -8,15 +8,15 @@ exclude = ["assets/"] [dependencies] # ----- Internal dependencies bevy_ghx_proc_gen = { path = "../bevy_ghx_proc_gen", default-features = true } -bevy_ghx_utils = { version = "0.3.0", default-features = true } +bevy_ghx_utils = { version = "0.4", default-features = true } # ----- External dependencies tracing-subscriber = "0.3.18" rand = "0.8.5" -bevy = { version = "0.13.0", default-features = false, features = [ +bevy = { version = "0.14", default-features = false, features = [ # Default features: - "multi-threaded", # Run with multithreading + "multi_threaded", # Run with multithreading "bevy_asset", # Assets management "bevy_scene", # Scenes management "bevy_render", # Rendering framework core @@ -43,7 +43,7 @@ bevy = { version = "0.13.0", default-features = false, features = [ # Development/Debug features: "dynamic_linking", # Dynamic linking for faster compile-times ] } -bevy_mod_picking = { version = "0.18.0", default-features = false, features = [ +bevy_mod_picking = { version = "0.20.0", default-features = false, features = [ "backend_raycast", "backend_bevy_ui", "backend_sprite", diff --git a/bevy_examples/canyon/canyon.rs b/bevy_examples/canyon/canyon.rs index dafefa5..3cd2868 100644 --- a/bevy_examples/canyon/canyon.rs +++ b/bevy_examples/canyon/canyon.rs @@ -1,6 +1,11 @@ use std::f32::consts::PI; -use bevy::{log::LogPlugin, pbr::DirectionalLightShadowMap, prelude::*}; +use bevy::{ + color::palettes::css::{GRAY, ORANGE_RED}, + log::LogPlugin, + pbr::DirectionalLightShadowMap, + prelude::*, +}; use bevy_examples::{ anim::SpawningScaleAnimation, plugin::ProcGenExamplesPlugin, utils::load_assets, @@ -8,7 +13,7 @@ use bevy_examples::{ use bevy_ghx_proc_gen::{ bevy_ghx_grid::{ debug_plugin::{view::DebugGridView, DebugGridView3dBundle}, - ghx_grid::{coordinate_system::Cartesian3D, grid::GridDefinition}, + ghx_grid::{cartesian::{coordinates::Cartesian3D, grid::CartesianGrid}, grid::GridData}, }, gen::{ assets::AssetSpawner, @@ -20,7 +25,7 @@ use bevy_ghx_proc_gen::{ }, GeneratorBundle, }; -use bevy_ghx_utils::camera::{update_pan_orbit_camera, PanOrbitCamera}; +use bevy_ghx_utils::camera::{update_pan_orbit_camera, PanOrbitCameraBundle, PanOrbitState}; use rand::Rng; use rules::{CustomComponents, RotationRandomizer, ScaleRandomizer, WindRotation}; @@ -56,28 +61,29 @@ fn setup_scene(mut commands: Commands) { let camera_position = Vec3::new(0., 1.5 * GRID_HEIGHT as f32, 1.5 * GRID_Z as f32 / 2.); let look_target = Vec3::new(0., -10., 0.); let radius = (look_target - camera_position).length(); - commands.spawn(( - Camera3dBundle { + commands.spawn((PanOrbitCameraBundle { + camera: Camera3dBundle { transform: Transform::from_translation(camera_position) .looking_at(look_target, Vec3::Y), ..default() }, - PanOrbitCamera { + state: PanOrbitState { radius, - ..Default::default() + ..default() }, - )); + ..Default::default() + },)); // Scene lights commands.insert_resource(AmbientLight { - color: Color::ORANGE_RED, + color: ORANGE_RED.into(), brightness: 0.05, }); commands.spawn(DirectionalLightBundle { directional_light: DirectionalLight { shadows_enabled: true, illuminance: 4000., - color: Color::rgb(1.0, 0.85, 0.65), + color: Color::srgb(1.0, 0.85, 0.65).into(), ..default() }, transform: Transform { @@ -91,7 +97,7 @@ fn setup_scene(mut commands: Commands) { directional_light: DirectionalLight { shadows_enabled: false, illuminance: 2000., - color: Color::ORANGE_RED, + color: ORANGE_RED.into(), ..default() }, transform: Transform { @@ -118,9 +124,13 @@ fn setup_generator(mut commands: Commands, asset_server: Res) { let rules = RulesBuilder::new_cartesian_3d(models, socket_collection) .build() .unwrap(); - let grid = GridDefinition::new_cartesian_3d(GRID_X, GRID_HEIGHT, GRID_Z, false, false, false); + let grid = CartesianGrid::new_cartesian_3d(GRID_X, GRID_HEIGHT, GRID_Z, false, false, false); + + let grid_size = (grid.size_xy() * grid.size_z()) as usize; - let mut initial_constraints = grid.new_grid_data(None); + + //let mut initial_constraints = grid.new_grid_data(None); + let mut initial_constraints: GridData> = GridData::new(grid.clone(), vec![None; grid_size]); // Force void nodes on the upmost layer let void_ref = Some(void_instance); initial_constraints.set_all_y(GRID_HEIGHT - 1, void_ref); @@ -137,9 +147,10 @@ fn setup_generator(mut commands: Commands, asset_server: Res) { initial_constraints.set_all_yz(0, GRID_Z - 1, sand_ref); // Let's force a small lake at the center let water_ref = Some(water_instance); - for x in 2 * GRID_X / 5..3 * GRID_X / 5 { + // TODO! Fix this code + /*for x in 2 * GRID_X / 5..3 * GRID_X / 5 { for z in 2 * GRID_Z / 5..3 * GRID_Z / 5 { - initial_constraints.set((x, 0, z), water_ref); + initial_constraints.set((x as usize, 0 as usize, z as usize), water_ref); } } // We could hope for a water bridge, or force one ! @@ -147,7 +158,7 @@ fn setup_generator(mut commands: Commands, asset_server: Res) { (GRID_X / 2, GRID_HEIGHT / 2, GRID_Z / 2), Some(bridge_instance), ); - + */ let mut gen_builder = GeneratorBuilder::new() .with_rules(rules) .with_grid(grid.clone()) @@ -187,7 +198,7 @@ fn setup_generator(mut commands: Commands, asset_server: Res) { }, observer, DebugGridView3dBundle { - view: DebugGridView::new(false, true, Color::GRAY, NODE_SIZE), + view: DebugGridView::new(false, true, GRAY.into(), NODE_SIZE), ..default() }, )); diff --git a/bevy_examples/canyon/rules.rs b/bevy_examples/canyon/rules.rs index 5e5afa2..342e8e8 100644 --- a/bevy_examples/canyon/rules.rs +++ b/bevy_examples/canyon/rules.rs @@ -1,7 +1,7 @@ use bevy::{ecs::component::Component, math::Vec3}; use bevy_examples::utils::AssetDef; use bevy_ghx_proc_gen::{ - bevy_ghx_grid::ghx_grid::{coordinate_system::Cartesian3D, direction::GridDelta}, + bevy_ghx_grid::ghx_grid::cartesian::coordinates::{Cartesian3D, GridDelta}, gen::assets::ComponentSpawner, proc_gen::generator::{ model::{ModelCollection, ModelInstance, ModelRotation}, diff --git a/bevy_examples/chessboard/chessboard.rs b/bevy_examples/chessboard/chessboard.rs index 9702d3c..d0c647b 100644 --- a/bevy_examples/chessboard/chessboard.rs +++ b/bevy_examples/chessboard/chessboard.rs @@ -1,10 +1,7 @@ use bevy::prelude::*; use bevy_ghx_proc_gen::{ - bevy_ghx_grid::ghx_grid::{ - coordinate_system::Cartesian2D, - grid::{GridDefinition, GridPosition}, - }, + bevy_ghx_grid::ghx_grid::cartesian::{coordinates::Cartesian2D, grid::CartesianGrid}, gen::{ assets::{AssetSpawner, RulesModelsAssets}, default_bundles::PbrMesh, @@ -65,14 +62,15 @@ fn setup_generator( .unwrap(); // Like a chess board, let's do an 8x8 2d grid - let grid = GridDefinition::new_cartesian_2d(8, 8, false, false); + let grid = CartesianGrid::new_cartesian_2d(8, 8, false, false); + let initial_nodes = vec![(grid.index_from_coords(0, 0, 0), black_model)]; // There many more parameters you can tweak on a Generator before building it, explore the API. let generator = GeneratorBuilder::new() .with_rules(rules) .with_grid(grid.clone()) // Let's ensure that we make a chessboard, with a black square bottom-left - .with_initial_nodes(vec![(GridPosition::new_xy(0, 0), black_model)]) + .with_initial_nodes(initial_nodes) .unwrap() .build() .unwrap(); diff --git a/bevy_examples/pillars/pillars.rs b/bevy_examples/pillars/pillars.rs index 187636d..0fddcf3 100644 --- a/bevy_examples/pillars/pillars.rs +++ b/bevy_examples/pillars/pillars.rs @@ -1,13 +1,18 @@ use std::{f32::consts::PI, sync::Arc}; -use bevy::{log::LogPlugin, pbr::DirectionalLightShadowMap, prelude::*}; +use bevy::{ + color::palettes::{basic::GRAY, css::ORANGE_RED}, + log::LogPlugin, + pbr::DirectionalLightShadowMap, + prelude::*, +}; use bevy_examples::{plugin::ProcGenExamplesPlugin, utils::load_assets}; use bevy_ghx_proc_gen::{ bevy_ghx_grid::{ debug_plugin::{view::DebugGridView, DebugGridView3dBundle}, - ghx_grid::{coordinate_system::Cartesian3D, grid::GridDefinition}, + ghx_grid::cartesian::{coordinates::Cartesian3D, grid::CartesianGrid}, }, gen::{ assets::{AssetSpawner, RulesModelsAssets}, @@ -16,7 +21,7 @@ use bevy_ghx_proc_gen::{ proc_gen::generator::{builder::GeneratorBuilder, rules::RulesBuilder}, GeneratorBundle, }; -use bevy_ghx_utils::camera::{update_pan_orbit_camera, PanOrbitCamera}; +use bevy_ghx_utils::camera::{update_pan_orbit_camera, PanOrbitCameraBundle, PanOrbitState}; use crate::rules::rules_and_assets; @@ -48,16 +53,19 @@ fn setup_scene( let camera_position = Vec3::new(0., 3. * GRID_HEIGHT as f32, 0.75 * GRID_Z as f32); let radius = camera_position.length(); commands.spawn(( - Camera3dBundle { - transform: Transform::from_translation(camera_position).looking_at(Vec3::ZERO, Vec3::Y), + PanOrbitCameraBundle { + camera: Camera3dBundle { + transform: Transform::from_translation(camera_position).looking_at(Vec3::ZERO, Vec3::Y), + ..default() + }, + state: PanOrbitState { + radius, + ..default() + }, ..default() }, - PanOrbitCamera { - radius, - ..Default::default() - }, FogSettings { - color: Color::rgba(0.2, 0.15, 0.1, 1.0), + color: Color::srgba(0.2, 0.15, 0.1, 1.0).into(), falloff: FogFalloff::Linear { start: 55.0, end: 145.0, @@ -69,7 +77,7 @@ fn setup_scene( PbrBundle { mesh: meshes.add(Mesh::from(Plane3d::default())), material: materials.add(StandardMaterial { - base_color: Color::hex("888888").unwrap(), + base_color: Color::srgb_u8(136, 136, 136).into(), ..default() }), transform: Transform::from_scale(Vec3::splat(10000.0)).with_translation(Vec3::new( @@ -84,14 +92,14 @@ fn setup_scene( // Scene lights commands.insert_resource(AmbientLight { - color: Color::ORANGE_RED, + color: ORANGE_RED.into(), brightness: 0.05, }); commands.spawn(DirectionalLightBundle { directional_light: DirectionalLight { shadows_enabled: true, illuminance: 3000., - color: Color::rgb(1.0, 0.85, 0.65), + color: Color::srgb(1.0, 0.85, 0.65).into(), ..default() }, transform: Transform { @@ -105,7 +113,7 @@ fn setup_scene( directional_light: DirectionalLight { shadows_enabled: false, illuminance: 1250., - color: Color::rgb(1.0, 0.85, 0.65), + color: Color::srgb(1.0, 0.85, 0.65).into(), ..default() }, transform: Transform { @@ -126,7 +134,7 @@ fn setup_generator(mut commands: Commands, asset_server: Res) { .build() .unwrap(), ); - let grid = GridDefinition::new_cartesian_3d(GRID_X, GRID_HEIGHT, GRID_Z, false, false, false); + let grid = CartesianGrid::new_cartesian_3d(GRID_X, GRID_HEIGHT, GRID_Z, false, false, false); let gen_builder = GeneratorBuilder::new() // We share the Rules between all the generators .with_shared_rules(rules.clone()) @@ -160,7 +168,7 @@ fn setup_generator(mut commands: Commands, asset_server: Res) { }, observer, DebugGridView3dBundle { - view: DebugGridView::new(false, true, Color::GRAY, NODE_SIZE), + view: DebugGridView::new(false, true, GRAY.into(), NODE_SIZE), ..default() }, Name::new(format!("Grid_{}", i)), diff --git a/bevy_examples/pillars/rules.rs b/bevy_examples/pillars/rules.rs index 67781e8..93b04a3 100644 --- a/bevy_examples/pillars/rules.rs +++ b/bevy_examples/pillars/rules.rs @@ -1,6 +1,6 @@ use bevy_examples::utils::AssetDef; use bevy_ghx_proc_gen::{ - bevy_ghx_grid::ghx_grid::coordinate_system::Cartesian3D, + bevy_ghx_grid::ghx_grid::cartesian::coordinates::Cartesian3D, proc_gen::generator::{ model::ModelCollection, socket::{SocketCollection, SocketsCartesian3D}, diff --git a/bevy_examples/src/fps.rs b/bevy_examples/src/fps.rs index b9b9cb5..0c545a1 100644 --- a/bevy_examples/src/fps.rs +++ b/bevy_examples/src/fps.rs @@ -1,5 +1,9 @@ use bevy::{ app::{App, Plugin, Startup, Update}, + color::{ + palettes::basic::{BLACK, WHITE}, + Color, + }, diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin}, ecs::{ component::Component, @@ -7,7 +11,8 @@ use bevy::{ system::{Commands, Query, Res}, }, hierarchy::BuildChildren, - render::{color::Color, view::Visibility}, + prelude::Alpha, + render::view::Visibility, text::{Text, TextSection, TextStyle}, ui::{ node_bundles::{NodeBundle, TextBundle}, @@ -45,7 +50,7 @@ pub fn setup_fps_counter(mut commands: Commands) { FpsRoot, NodeBundle { // give it a dark background for readability - background_color: BackgroundColor(Color::BLACK.with_a(0.5)), + background_color: BackgroundColor(BLACK.with_alpha(0.5).into()), // make it "always on top" by setting the Z index to maximum // we want it to be displayed over all other UI z_index: ZIndex::Global(i32::MAX), @@ -79,7 +84,7 @@ pub fn setup_fps_counter(mut commands: Commands) { value: "FPS: ".into(), style: TextStyle { font_size: DEFAULT_EXAMPLES_FONT_SIZE, - color: Color::WHITE, + color: WHITE.into(), // if you want to use your game's font asset, // uncomment this and provide the handle: // font: my_font_handle @@ -90,7 +95,7 @@ pub fn setup_fps_counter(mut commands: Commands) { value: " N/A".into(), style: TextStyle { font_size: DEFAULT_EXAMPLES_FONT_SIZE, - color: Color::WHITE, + color: WHITE.into(), // if you want to use your game's font asset, // uncomment this and provide the handle: // font: my_font_handle @@ -124,22 +129,22 @@ pub fn fps_text_update_system( // text according to the FPS value: text.sections[1].style.color = if value >= 120.0 { // Above 120 FPS, use green color - Color::rgb(0.0, 1.0, 0.0) + Color::srgb(0.0, 1.0, 0.0) } else if value >= 60.0 { // Between 60-120 FPS, gradually transition from yellow to green - Color::rgb((1.0 - (value - 60.0) / (120.0 - 60.0)) as f32, 1.0, 0.0) + Color::srgb((1.0 - (value - 60.0) / (120.0 - 60.0)) as f32, 1.0, 0.0) } else if value >= 30.0 { // Between 30-60 FPS, gradually transition from red to yellow - Color::rgb(1.0, ((value - 30.0) / (60.0 - 30.0)) as f32, 0.0) + Color::srgb(1.0, ((value - 30.0) / (60.0 - 30.0)) as f32, 0.0) } else { // Below 30 FPS, use red color - Color::rgb(1.0, 0.0, 0.0) + Color::srgb(1.0, 0.0, 0.0) } } else { // display "N/A" if we can't get a FPS measurement // add an extra space to preserve alignment text.sections[1].value = " N/A".into(); - text.sections[1].style.color = Color::WHITE; + text.sections[1].style.color = WHITE.into(); } } } diff --git a/bevy_examples/src/plugin.rs b/bevy_examples/src/plugin.rs index 07b4dbf..ae6d9b9 100644 --- a/bevy_examples/src/plugin.rs +++ b/bevy_examples/src/plugin.rs @@ -2,6 +2,10 @@ use std::marker::PhantomData; use bevy::{ app::{App, Plugin, PreUpdate, Startup, Update}, + color::{ + palettes::css::{GREEN, YELLOW_GREEN}, + Color, + }, diagnostic::FrameTimeDiagnosticsPlugin, ecs::{ component::Component, @@ -19,8 +23,7 @@ use bevy::{ ButtonInput, }, math::Vec3, - prelude::default, - render::color::Color, + prelude::{default, Alpha}, text::{BreakLineOn, Text, TextSection, TextStyle}, ui::{ node_bundles::{NodeBundle, TextBundle}, @@ -34,7 +37,9 @@ use bevy_ghx_proc_gen::{ markers::MarkersGroup, toggle_debug_grids_visibilities, toggle_grid_markers_visibilities, GridDebugPlugin, }, - ghx_grid::coordinate_system::CoordinateSystem, + ghx_grid::{ + cartesian::coordinates::CartesianCoordinates, coordinate_system::CoordinateSystem, + }, }, gen::{ assets::{AssetsBundleSpawner, ComponentSpawner, NoComponents}, @@ -80,7 +85,7 @@ impl const DEFAULT_SPAWN_ANIMATION_DURATION: f32 = 0.6; const FAST_SPAWN_ANIMATION_DURATION: f32 = 0.1; -impl Plugin +impl Plugin for ProcGenExamplesPlugin { fn build(&self, app: &mut App) { @@ -126,7 +131,7 @@ impl Plugin PreUpdate, absorb_egui_inputs .after(bevy_egui::systems::process_input_system) - .before(bevy_egui::EguiSet::BeginFrame), + .before(bevy_egui::EguiSet::BeginPass), ); } } @@ -197,7 +202,7 @@ pub fn setup_ui(mut commands: Commands, view_mode: Res) { .spawn(( Pickable::IGNORE, NodeBundle { - background_color: Color::BLACK.with_a(0.6).into(), + background_color: Color::BLACK.with_alpha(0.6).into(), style: Style { position_type: PositionType::Absolute, top: Val::Percent(1.), @@ -298,9 +303,9 @@ pub fn update_generation_control_ui( for mut text in &mut query { let status_section = &mut text.sections[GENERATION_CONTROL_STATUS_TEXT_SECTION_ID]; (status_section.value, status_section.style.color) = match gen_control.status { - GenerationControlStatus::Ongoing => ("Ongoing ('Space' to pause)".into(), Color::GREEN), + GenerationControlStatus::Ongoing => ("Ongoing ('Space' to pause)".into(), GREEN.into()), GenerationControlStatus::Paused => { - ("Paused ('Space' to unpause)".into(), Color::YELLOW_GREEN) + ("Paused ('Space' to unpause)".into(), YELLOW_GREEN.into()) } }; diff --git a/bevy_examples/src/utils.rs b/bevy_examples/src/utils.rs index 0a7d36f..88dc542 100644 --- a/bevy_examples/src/utils.rs +++ b/bevy_examples/src/utils.rs @@ -5,7 +5,7 @@ use bevy::{ }; use bevy_ghx_proc_gen::{ - bevy_ghx_grid::ghx_grid::direction::GridDelta, + bevy_ghx_grid::ghx_grid::cartesian::coordinates::GridDelta, gen::assets::{ AssetsBundleSpawner, ComponentSpawner, ModelAsset, NoComponents, RulesModelsAssets, }, diff --git a/bevy_examples/tile-layers/rules.rs b/bevy_examples/tile-layers/rules.rs index 7c473c7..349906b 100644 --- a/bevy_examples/tile-layers/rules.rs +++ b/bevy_examples/tile-layers/rules.rs @@ -2,8 +2,8 @@ use bevy_examples::utils::AssetDef; use bevy_ghx_proc_gen::{ bevy_ghx_grid::ghx_grid::{ - coordinate_system::Cartesian3D, - direction::{Direction, GridDelta}, + cartesian::coordinates::{Cartesian3D, GridDelta}, + direction::Direction, }, proc_gen::generator::{ model::{ModelCollection, ModelRotation}, diff --git a/bevy_examples/tile-layers/tile-layers.rs b/bevy_examples/tile-layers/tile-layers.rs index 5212fa0..b37bede 100644 --- a/bevy_examples/tile-layers/tile-layers.rs +++ b/bevy_examples/tile-layers/tile-layers.rs @@ -1,15 +1,13 @@ use bevy::{ app::{App, PluginGroup, Startup}, asset::{AssetServer, Handle}, + color::Color, core_pipeline::core_2d::Camera2dBundle, ecs::system::{Commands, Res}, log::LogPlugin, math::Vec3, prelude::SpatialBundle, - render::{ - color::Color, - texture::{Image, ImagePlugin}, - }, + render::texture::{Image, ImagePlugin}, transform::components::Transform, utils::default, DefaultPlugins, @@ -19,7 +17,10 @@ use bevy_examples::{plugin::ProcGenExamplesPlugin, utils::load_assets}; use bevy_ghx_proc_gen::{ bevy_ghx_grid::{ debug_plugin::{view::DebugGridView, DebugGridView2dBundle}, - ghx_grid::{coordinate_system::Cartesian3D, direction::Direction, grid::GridDefinition}, + ghx_grid::{ + cartesian::{coordinates::Cartesian3D, grid::CartesianGrid}, + direction::Direction, + }, }, gen::{ assets::{AssetSpawner, RulesModelsAssets}, @@ -74,7 +75,7 @@ fn setup_generator(mut commands: Commands, asset_server: Res) { .with_rotation_axis(Direction::ZForward) .build() .unwrap(); - let grid = GridDefinition::new_cartesian_3d(GRID_X, GRID_Y, GRID_Z, false, false, false); + let grid = CartesianGrid::new_cartesian_3d(GRID_X, GRID_Y, GRID_Z, false, false, false); let mut gen_builder = GeneratorBuilder::new() .with_rules(rules) .with_grid(grid.clone()) diff --git a/bevy_ghx_proc_gen/Cargo.toml b/bevy_ghx_proc_gen/Cargo.toml index 24d3903..13ddb9a 100644 --- a/bevy_ghx_proc_gen/Cargo.toml +++ b/bevy_ghx_proc_gen/Cargo.toml @@ -47,15 +47,17 @@ ghx_proc_gen = { path = "../ghx_proc_gen", version = "0.2.0", features = [ ] } # ----- External dependencies -bevy = { version = "0.13.0", default-features = false, features = [ +bevy = { version = "0.14", default-features = false, features = [ "bevy_render", # Rendering framework core + "bevy_winit", + "wayland", # Needed for some reason ] } # ----- Optional dependencies -bevy_ghx_grid = { version = "0.2.1", optional = true, features = [] } +bevy_ghx_grid = { version = "0.4", optional = true, features = [] } # Only enabled when the "picking" feature is enabled -bevy_mod_picking = { version = "0.18.0", optional = true, default-features = false } +bevy_mod_picking = { version = "0.20", optional = true, default-features = false } # Bevy_mod_picking depends on this version of bevy_egui -bevy_egui = { version = "0.25.0", optional = true, default-features = false, features = [ +bevy_egui = { version = "0.30", optional = true, default-features = false, features = [ "default_fonts", ] } diff --git a/bevy_ghx_proc_gen/src/gen.rs b/bevy_ghx_proc_gen/src/gen.rs index d5dae74..aea8dd6 100644 --- a/bevy_ghx_proc_gen/src/gen.rs +++ b/bevy_ghx_proc_gen/src/gen.rs @@ -9,8 +9,11 @@ use bevy::{ hierarchy::BuildChildren, math::Vec3, }; -use bevy_ghx_grid::ghx_grid::{coordinate_system::CoordinateSystem, grid::GridDefinition}; -use ghx_proc_gen::{generator::model::ModelInstance, NodeIndex}; +use bevy_ghx_grid::ghx_grid::cartesian::{coordinates::GridDelta, grid::CartesianGrid}; +use ghx_proc_gen::{ + generator::model::ModelInstance, ghx_grid::cartesian::coordinates::CartesianCoordinates, + NodeIndex, +}; use self::assets::{AssetSpawner, AssetsBundleSpawner, ComponentSpawner}; @@ -112,10 +115,10 @@ pub fn insert_bundle_from_resource_to_spawned_nodes>(...); /// ``` -pub fn spawn_node( +pub fn spawn_node( commands: &mut Commands, gen_entity: Entity, - grid: &GridDefinition, + grid: &CartesianGrid, asset_spawner: &AssetSpawner, instance: &ModelInstance, node_index: NodeIndex, diff --git a/bevy_ghx_proc_gen/src/gen/assets.rs b/bevy_ghx_proc_gen/src/gen/assets.rs index 9e281b9..5fb87ce 100644 --- a/bevy_ghx_proc_gen/src/gen/assets.rs +++ b/bevy_ghx_proc_gen/src/gen/assets.rs @@ -4,11 +4,11 @@ use std::{ sync::Arc, }; +use crate::gen::GridDelta; use bevy::{ ecs::{component::Component, system::EntityCommands}, math::Vec3, }; -use bevy_ghx_grid::ghx_grid::direction::GridDelta; use ghx_proc_gen::generator::model::{ModelIndex, ModelRotation}; /// Defines a struct which can spawn an assets [`bevy::prelude::Bundle`] (for example, a [`bevy::prelude::SpriteBundle`], a [`bevy::prelude::PbrBundle`], a [`bevy::prelude::SceneBundle`], ...). diff --git a/bevy_ghx_proc_gen/src/gen/debug_plugin.rs b/bevy_ghx_proc_gen/src/gen/debug_plugin.rs index 645d58d..d5f05d6 100644 --- a/bevy_ghx_proc_gen/src/gen/debug_plugin.rs +++ b/bevy_ghx_proc_gen/src/gen/debug_plugin.rs @@ -1,13 +1,14 @@ +use crate::gen::CartesianCoordinates; use std::{marker::PhantomData, time::Duration}; use bevy::{ app::{App, Plugin, PostStartup, PostUpdate, PreUpdate, Startup, Update}, + color::Color, ecs::{schedule::IntoSystemConfigs, system::Resource}, input::keyboard::KeyCode, - render::color::Color, + prelude::Alpha, time::{Timer, TimerMode}, }; -use bevy_ghx_grid::ghx_grid::coordinate_system::CoordinateSystem; use self::{ cursor::{ @@ -86,7 +87,7 @@ impl Default for GridCursorsUiSettings { fn default() -> Self { Self { font_size: 16.0, - background_color: Color::BLACK.with_a(0.45), + background_color: Color::BLACK.with_alpha(0.45), text_color: Color::WHITE, } } @@ -98,7 +99,7 @@ impl Default for GridCursorsUiSettings { /// /// It also uses the following `Resources`: [`ProcGenKeyBindings`] and [`GenerationControl`] (and will init them to their defaults if not inserted by the user). pub struct ProcGenDebugPlugin< - C: CoordinateSystem, + C: CartesianCoordinates, A: AssetsBundleSpawner, T: ComponentSpawner = NoComponents, > { @@ -107,7 +108,9 @@ pub struct ProcGenDebugPlugin< typestate: PhantomData<(C, A, T)>, } -impl ProcGenDebugPlugin { +impl + ProcGenDebugPlugin +{ /// Plugin constructor pub fn new(generation_view_mode: GenerationViewMode, cursor_ui_mode: CursorUiMode) -> Self { Self { @@ -118,7 +121,7 @@ impl ProcGenDe } } -impl Plugin +impl Plugin for ProcGenDebugPlugin { // TODO Clean: Split into multiple plugins diff --git a/bevy_ghx_proc_gen/src/gen/debug_plugin/cursor.rs b/bevy_ghx_proc_gen/src/gen/debug_plugin/cursor.rs index 434d6ee..52ef3f0 100644 --- a/bevy_ghx_proc_gen/src/gen/debug_plugin/cursor.rs +++ b/bevy_ghx_proc_gen/src/gen/debug_plugin/cursor.rs @@ -1,6 +1,8 @@ +use crate::gen::CartesianCoordinates; use std::{fmt, time::Duration}; use bevy::{ + color::Color, core::Name, ecs::{ component::Component, @@ -12,7 +14,8 @@ use bevy::{ hierarchy::BuildChildren, input::{keyboard::KeyCode, ButtonInput}, log::warn, - render::{camera::Camera, color::Color}, + prelude::Srgba, + render::camera::Camera, text::{BreakLineOn, Text, TextSection, TextStyle}, time::{Time, Timer, TimerMode}, transform::components::GlobalTransform, @@ -25,9 +28,9 @@ use bevy::{ use bevy_ghx_grid::{ debug_plugin::markers::{spawn_marker, GridMarker, MarkerDespawnEvent}, ghx_grid::{ + cartesian::{coordinates::CartesianPosition, grid::CartesianGrid}, coordinate_system::CoordinateSystem, direction::Direction, - grid::{GridDefinition, GridPosition}, }, }; use ghx_proc_gen::{ @@ -70,7 +73,7 @@ pub struct TargetedNode { /// Index of the node in its grid pub node_index: NodeIndex, /// Position of the node in its grid - pub position: GridPosition, + pub position: CartesianPosition, /// Marker entity for this targeted node pub marker: Entity, } @@ -126,7 +129,7 @@ pub trait CursorMarkerSettings: Resource { pub struct SelectionCursorMarkerSettings(pub Color); impl Default for SelectionCursorMarkerSettings { fn default() -> Self { - Self(Color::GREEN) + Self(Srgba::rgb(0.0, 0.5019608, 0.0).into()) } } impl CursorMarkerSettings for SelectionCursorMarkerSettings { @@ -218,7 +221,7 @@ pub fn setup_cursors_overlays(mut commands: Commands) { } /// Setup system to spawn a cursor and its overlay -pub fn setup_cursor( +pub fn setup_cursor( mut commands: Commands, overlays_root: Query>, ) { @@ -248,7 +251,7 @@ pub fn setup_cursor( } /// System updating all the [CursorInfo] components when [Cursor] components are changed -pub fn update_cursors_info_on_cursors_changes( +pub fn update_cursors_info_on_cursors_changes( mut moved_cursors: Query<(&mut CursorInfo, &Cursor), Changed>, generators: Query<&Generator>, ) { @@ -268,7 +271,7 @@ pub fn update_cursors_info_on_cursors_changes( } /// System updating all the [CursorInfo] based on [GenerationEvent] -pub fn update_cursors_info_from_generation_events( +pub fn update_cursors_info_from_generation_events( mut cursors_events: EventReader, generators: Query<&Generator>, mut cursors: Query<(&Cursor, &mut CursorInfo)>, @@ -375,7 +378,7 @@ impl EntityProvider { } /// System that listens to the generation switch [KeyCode] to switch the current active generation grid -pub fn switch_generation_selection_from_keybinds( +pub fn switch_generation_selection_from_keybinds( mut local_grid_cycler: Local, mut commands: Commands, mut active_generation: ResMut, @@ -384,7 +387,7 @@ pub fn switch_generation_selection_from_keybinds( proc_gen_key_bindings: Res, mut marker_events: EventWriter, mut selection_cursor: Query<&mut Cursor, With>, - generators: Query>, With>)>, + generators: Query>, With>)>, ) { if keys.just_pressed(proc_gen_key_bindings.switch_grid) { let Ok(mut cursor) = selection_cursor.get_single_mut() else { @@ -402,7 +405,7 @@ pub fn switch_generation_selection_from_keybinds( cursor.0 = Some(spawn_marker_and_create_cursor( &mut commands, grid_entity, - GridPosition::new(0, 0, 0), + CartesianPosition::new(0, 0, 0), 0, selection_marker_settings.color(), )); @@ -462,7 +465,7 @@ impl Default for CursorKeyboardMovement { } /// System handling movements of the selection cursor from the keyboard -pub fn move_selection_from_keybinds( +pub fn move_selection_from_keybinds( mut commands: Commands, keys: Res>, time: Res