update to bevy 0.18
This commit is contained in:
5833
Cargo.lock
generated
5833
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@ edition = "2021"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = "1.0.204"
|
serde = "1.0.228"
|
||||||
serde_json = "1.0.120"
|
serde_json = "1.0.149"
|
||||||
bevy = "0.16.0"
|
bevy = "0.18.0"
|
||||||
ron = "0.8.1"
|
ron = "0.12.0"
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use bevy::{asset::AssetLoader, reflect::TypePath};
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! create_asset_loader {
|
macro_rules! create_asset_loader {
|
||||||
(
|
(
|
||||||
@@ -9,7 +11,7 @@ macro_rules! create_asset_loader {
|
|||||||
$($string_array_name: ident -> $handle_array_name: ident)* ?
|
$($string_array_name: ident -> $handle_array_name: ident)* ?
|
||||||
) => {
|
) => {
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::asset::{AssetLoader, AssetEvent, AssetEvents, LoadContext, LoadState, AsyncReadExt, io::Reader};
|
use bevy::asset::{AssetLoader, AssetEvent, LoadContext, LoadState, AsyncReadExt, io::Reader};
|
||||||
pub struct $plugin_name;
|
pub struct $plugin_name;
|
||||||
impl Plugin for $plugin_name {
|
impl Plugin for $plugin_name {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
@@ -18,7 +20,7 @@ macro_rules! create_asset_loader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default, TypePath)]
|
||||||
pub struct $loader_name;
|
pub struct $loader_name;
|
||||||
|
|
||||||
impl AssetLoader for $loader_name {
|
impl AssetLoader for $loader_name {
|
||||||
@@ -30,10 +32,10 @@ macro_rules! create_asset_loader {
|
|||||||
|
|
||||||
async fn load(
|
async fn load(
|
||||||
&self,
|
&self,
|
||||||
reader: & mut dyn bevy::asset::io::Reader,
|
reader: &mut dyn bevy::asset::io::Reader,
|
||||||
_: &Self::Settings,
|
settings: &Self::Settings,
|
||||||
load_context: &mut LoadContext<'_>,
|
load_context: &mut bevy::asset::LoadContext<'_>,
|
||||||
) -> Result<Self::Asset, Self::Error> {
|
) -> Result<Self::Asset, Self::Error>{
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = Vec::new();
|
||||||
let read_result = reader.read_to_end(&mut bytes).await;
|
let read_result = reader.read_to_end(&mut bytes).await;
|
||||||
if read_result.is_err() {
|
if read_result.is_err() {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ edition = "2021"
|
|||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = "1.0.204"
|
serde = "1.0.228"
|
||||||
serde_json = "1.0.120"
|
serde_json = "1.0.149"
|
||||||
bevy = "0.16.0"
|
bevy = "0.18.0"
|
||||||
ron = "0.8.1"
|
ron = "0.12.0"
|
||||||
|
|||||||
@@ -6,19 +6,19 @@ edition = "2021"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.16.0"
|
bevy = "0.18.0"
|
||||||
noise = "0.9.0"
|
noise = "0.9.0"
|
||||||
serde = { version = "1.0.203", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
serde_json = "1.0.115"
|
serde_json = "1.0.149"
|
||||||
asset_loader = { path = "../asset_loader" }
|
asset_loader = { path = "../asset_loader" }
|
||||||
rayon = "1.10.0"
|
rayon = "1.11.0"
|
||||||
bevy-inspector-egui = "0.28.1"
|
bevy-inspector-egui = "0.36.0"
|
||||||
bevy_asset_loader = { version = "0.23.0-rc.3", features = [
|
bevy_asset_loader = { version = "0.25.0", features = [
|
||||||
"standard_dynamic_assets",
|
"standard_dynamic_assets",
|
||||||
"3d",
|
"3d",
|
||||||
] }
|
] }
|
||||||
ron = "0.8.1"
|
ron = "0.12.0"
|
||||||
image = "0.25.2"
|
image = "0.25.9"
|
||||||
num = "0.4.3"
|
num = "0.4.3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
use bevy::{
|
use bevy::{mesh::MeshVertexAttribute, prelude::*, render::render_resource::VertexFormat};
|
||||||
prelude::*,
|
|
||||||
render::{mesh::MeshVertexAttribute, render_resource::VertexFormat},
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::hex_utils::{INNER_RADIUS, OUTER_RADIUS};
|
use crate::hex_utils::{INNER_RADIUS, OUTER_RADIUS};
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
use crate::hex_utils::HexCoord;
|
use crate::hex_utils::HexCoord;
|
||||||
use crate::{hex_utils::offset3d_to_world, prelude::*};
|
use crate::{hex_utils::offset3d_to_world, prelude::*};
|
||||||
|
use bevy::asset::RenderAssetUsages;
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
use bevy::log::*;
|
use bevy::log::*;
|
||||||
use bevy::{
|
use bevy::mesh::{Indices, PrimitiveTopology};
|
||||||
prelude::*,
|
use bevy::prelude::*;
|
||||||
render::{
|
|
||||||
mesh::{Indices, PrimitiveTopology},
|
|
||||||
render_asset::RenderAssetUsages,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn generate_chunk_mesh(chunk: &MeshChunkData) -> Mesh {
|
pub fn generate_chunk_mesh(chunk: &MeshChunkData) -> Mesh {
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
use crate::hex_utils::{offset3d_to_world, HexCoord};
|
use crate::hex_utils::HexCoord;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
use bevy::asset::RenderAssetUsages;
|
||||||
use bevy::{
|
use bevy::{
|
||||||
|
mesh::{Indices, PrimitiveTopology},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
render::{
|
|
||||||
mesh::{Indices, PrimitiveTopology},
|
|
||||||
render_asset::RenderAssetUsages,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn generate_packed_chunk_mesh(chunk: &MeshChunkData) -> Mesh {
|
pub fn generate_packed_chunk_mesh(chunk: &MeshChunkData) -> Mesh {
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ edition = "2021"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.16.0"
|
bevy = "0.18.0"
|
||||||
world_generation = { path = "../../engine/world_generation" }
|
world_generation = { path = "../../engine/world_generation" }
|
||||||
shared = { path = "../shared" }
|
shared = { path = "../shared" }
|
||||||
bevy_rapier3d = "0.29.0"
|
bevy_rapier3d = "0.33.0"
|
||||||
serde = { version = "1.0.204", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
asset_loader = { path = "../../engine/asset_loader" }
|
asset_loader = { path = "../../engine/asset_loader" }
|
||||||
serde_json = "1.0.120"
|
serde_json = "1.0.149"
|
||||||
ron = "0.8.1"
|
ron = "0.12.0"
|
||||||
bevy_asset_loader = { version = "0.23.0-rc.3", features = [
|
bevy_asset_loader = { version = "0.25.0", features = [
|
||||||
"standard_dynamic_assets",
|
"standard_dynamic_assets",
|
||||||
"3d",
|
"3d",
|
||||||
] }
|
] }
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use bevy::{
|
|||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use shared::{component_defination::ComponentDefination, identifiers::ResourceIdentifier, prefab_defination::*};
|
use shared::identifiers::ResourceIdentifier;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
buildings::{
|
buildings::{
|
||||||
@@ -32,7 +32,7 @@ pub struct BuildingAsset {
|
|||||||
pub health: u32,
|
pub health: u32,
|
||||||
|
|
||||||
pub building_type: BuildingType,
|
pub building_type: BuildingType,
|
||||||
pub components: Option<Vec<ComponentDefination>>,
|
// pub components: Option<Vec<ComponentDefination>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BuildingAsset {
|
impl BuildingAsset {
|
||||||
@@ -45,77 +45,78 @@ impl BuildingAsset {
|
|||||||
meshes: &Assets<GltfMesh>,
|
meshes: &Assets<GltfMesh>,
|
||||||
nodes: &Assets<GltfNode>,
|
nodes: &Assets<GltfNode>,
|
||||||
) -> Option<Entity> {
|
) -> Option<Entity> {
|
||||||
let base_node = &gltf.named_nodes[&self.base_mesh_path.clone().into_boxed_str()];
|
todo!("Update building spawning");
|
||||||
if let Some(node) = nodes.get(base_node.id()) {
|
// let base_node = &gltf.named_nodes[&self.base_mesh_path.clone().into_boxed_str()];
|
||||||
if let Some(mesh_handle) = &node.mesh {
|
// if let Some(node) = nodes.get(base_node.id()) {
|
||||||
if let Some(gltf_mesh) = meshes.get(mesh_handle.id()) {
|
// if let Some(mesh_handle) = &node.mesh {
|
||||||
let (mesh, mat) = gltf_mesh.unpack();
|
// if let Some(gltf_mesh) = meshes.get(mesh_handle.id()) {
|
||||||
let mut entity = commands.spawn((
|
// let (mesh, mat) = gltf_mesh.unpack();
|
||||||
Mesh3d(mesh),
|
// let mut entity = commands.spawn((
|
||||||
MeshMaterial3d(mat),
|
// Mesh3d(mesh),
|
||||||
Transform::from_translation(pos).with_rotation(rot),
|
// MeshMaterial3d(mat),
|
||||||
Building,
|
// Transform::from_translation(pos).with_rotation(rot),
|
||||||
));
|
// Building,
|
||||||
entity.with_children(|b| {
|
// ));
|
||||||
for child in &node.children {
|
// entity.with_children(|b| {
|
||||||
let child_node = nodes.get(child.id());
|
// for child in &node.children {
|
||||||
if child_node.is_none() {
|
// let child_node = nodes.get(child.id());
|
||||||
continue;
|
// if child_node.is_none() {
|
||||||
}
|
// continue;
|
||||||
self.process_node(child_node.unwrap(), meshes, nodes, b, &node.name);
|
// }
|
||||||
}
|
// self.process_node(child_node.unwrap(), meshes, nodes, b, &node.name);
|
||||||
});
|
// }
|
||||||
if let Some(component) = self.get_component_def(&format!("/{0}", &node.name)) {
|
// });
|
||||||
component.apply(&mut entity);
|
// if let Some(component) = self.get_component_def(&format!("/{0}", &node.name)) {
|
||||||
}
|
// component.apply(&mut entity);
|
||||||
return Some(entity.id());
|
// }
|
||||||
}
|
// return Some(entity.id());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return None;
|
// }
|
||||||
|
// return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_node(
|
// fn process_node(
|
||||||
&self,
|
// &self,
|
||||||
node: &GltfNode,
|
// node: &GltfNode,
|
||||||
meshes: &Assets<GltfMesh>,
|
// meshes: &Assets<GltfMesh>,
|
||||||
nodes: &Assets<GltfNode>,
|
// nodes: &Assets<GltfNode>,
|
||||||
commands: &mut ChildBuilder,
|
// commands: &mut ChildBuilder,
|
||||||
parent: &String,
|
// parent: &String,
|
||||||
) -> Option<Entity> {
|
// ) -> Option<Entity> {
|
||||||
let path = format!("{0}/{1}", parent, node.name);
|
// let path = format!("{0}/{1}", parent, node.name);
|
||||||
if let Some(mesh) = &node.mesh {
|
// if let Some(mesh) = &node.mesh {
|
||||||
if let Some(gltf_mesh) = meshes.get(mesh.id()) {
|
// if let Some(gltf_mesh) = meshes.get(mesh.id()) {
|
||||||
let (mesh, mat) = gltf_mesh.unpack();
|
// let (mesh, mat) = gltf_mesh.unpack();
|
||||||
let mut entity = commands.spawn((Mesh3d(mesh), MeshMaterial3d(mat), node.transform, Building));
|
// let mut entity = commands.spawn((Mesh3d(mesh), MeshMaterial3d(mat), node.transform, Building));
|
||||||
entity.with_children(|b| {
|
// entity.with_children(|b| {
|
||||||
for child in &node.children {
|
// for child in &node.children {
|
||||||
let child_node = nodes.get(child.id());
|
// let child_node = nodes.get(child.id());
|
||||||
if child_node.is_none() {
|
// if child_node.is_none() {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
self.process_node(child_node.unwrap(), meshes, nodes, b, &path);
|
// self.process_node(child_node.unwrap(), meshes, nodes, b, &path);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
if let Some(component) = self.get_component_def(&path) {
|
// if let Some(component) = self.get_component_def(&path) {
|
||||||
component.apply(&mut entity);
|
// component.apply(&mut entity);
|
||||||
}
|
// }
|
||||||
return Some(entity.id());
|
// return Some(entity.id());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return None;
|
// return None;
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn get_component_def(&self, path: &String) -> Option<&ComponentDefination> {
|
// fn get_component_def(&self, path: &String) -> Option<&ComponentDefination> {
|
||||||
if let Some(components) = &self.components {
|
// if let Some(components) = &self.components {
|
||||||
for c in components {
|
// for c in components {
|
||||||
if c.path.ends_with(path) {
|
// if c.path.ends_with(path) {
|
||||||
return Some(c);
|
// return Some(c);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return None;
|
// return None;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, TypePath)]
|
#[derive(Serialize, Deserialize, Debug, TypePath)]
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ impl Plugin for BuildingPugin {
|
|||||||
app.add_systems(Update, init.run_if(in_state(AssetLoadState::Loading)));
|
app.add_systems(Update, init.run_if(in_state(AssetLoadState::Loading)));
|
||||||
app.add_systems(
|
app.add_systems(
|
||||||
Update,
|
Update,
|
||||||
hq_placement.run_if(in_state(GameplayState::PlaceHQ).and_then(in_state(GeneratorState::Idle))),
|
hq_placement.run_if(in_state(GameplayState::PlaceHQ).and(in_state(GeneratorState::Idle))),
|
||||||
);
|
);
|
||||||
app.add_systems(
|
app.add_systems(
|
||||||
PreUpdate,
|
PreUpdate,
|
||||||
@@ -155,7 +155,7 @@ fn process_build_queue(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn update_building_heights(
|
fn update_building_heights(
|
||||||
mut tile_updates: EventReader<TileModifiedEvent>,
|
mut tile_updates: MessageReader<TileModifiedEvent>,
|
||||||
building_map: Res<BuildingMap>,
|
building_map: Res<BuildingMap>,
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -7,26 +7,26 @@ build = "build.rs"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = { version = "0.16.0", features = ["file_watcher"] }
|
bevy = { version = "0.18.0", features = ["file_watcher"] }
|
||||||
bevy-inspector-egui = "0.28.1"
|
bevy-inspector-egui = "0.36.0"
|
||||||
# iyes_perf_ui = "0.3.0"
|
# iyes_perf_ui = "0.3.0"
|
||||||
noise = "0.8.2"
|
noise = "0.9.0"
|
||||||
world_generation = { path = "../../engine/world_generation" }
|
world_generation = { path = "../../engine/world_generation" }
|
||||||
bevy_rapier3d = { version = "0.29.0", features = [
|
bevy_rapier3d = { version = "0.33.0", features = [
|
||||||
"simd-stable",
|
"simd-stable",
|
||||||
"parallel",
|
"parallel",
|
||||||
"debug-render-3d",
|
"debug-render-3d",
|
||||||
] }
|
] }
|
||||||
rayon = "1.10.0"
|
rayon = "1.11.0"
|
||||||
buildings = { path = "../buildings" }
|
buildings = { path = "../buildings" }
|
||||||
units = { path = "../units" }
|
units = { path = "../units" }
|
||||||
shared = { path = "../shared" }
|
shared = { path = "../shared" }
|
||||||
bevy_asset_loader = { version = "0.23.0-rc.3", features = [
|
bevy_asset_loader = { version = "0.25.0", features = [
|
||||||
"standard_dynamic_assets",
|
"standard_dynamic_assets",
|
||||||
"3d",
|
"3d",
|
||||||
] }
|
] }
|
||||||
ron = "0.8.1"
|
ron = "0.12.0"
|
||||||
image = "0.25.2"
|
image = "0.25.9"
|
||||||
# bevy_lunex = "0.2.4"
|
# bevy_lunex = "0.2.4"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use bevy::core_pipeline::experimental::taa::{TemporalAntiAliasBundle, TemporalAntiAliasPlugin, TemporalAntiAliasing};
|
use bevy::anti_alias::taa::{TemporalAntiAliasPlugin, TemporalAntiAliasing};
|
||||||
use bevy::core_pipeline::prepass::DepthPrepass;
|
use bevy::core_pipeline::prepass::DepthPrepass;
|
||||||
use bevy::input::mouse::{MouseMotion, MouseScrollUnit, MouseWheel};
|
use bevy::input::mouse::{MouseMotion, MouseScrollUnit, MouseWheel};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::window::{CursorGrabMode, PrimaryWindow};
|
use bevy::window::{CursorGrabMode, CursorOptions, PrimaryWindow};
|
||||||
use shared::sets::GameplaySet;
|
use shared::sets::GameplaySet;
|
||||||
use shared::tags::MainCamera;
|
use shared::tags::MainCamera;
|
||||||
use world_generation::hex_utils::HexCoord;
|
use world_generation::hex_utils::HexCoord;
|
||||||
@@ -30,10 +30,10 @@ impl Plugin for PhosCameraPlugin {
|
|||||||
|
|
||||||
fn init_bounds(
|
fn init_bounds(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut cam: Query<(&mut Transform, Entity), With<PhosCamera>>,
|
mut cam: Single<(&mut Transform, Entity), With<PhosCamera>>,
|
||||||
heightmap: Res<Map>,
|
heightmap: Res<Map>,
|
||||||
) {
|
) {
|
||||||
let (mut cam_t, cam_entity) = cam.single_mut();
|
let (mut cam_t, cam_entity) = cam.into_inner();
|
||||||
cam_t.translation = heightmap.get_center();
|
cam_t.translation = heightmap.get_center();
|
||||||
commands
|
commands
|
||||||
.entity(cam_entity)
|
.entity(cam_entity)
|
||||||
@@ -62,18 +62,17 @@ fn setup(mut commands: Commands) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn orbit_camera_upate(
|
fn orbit_camera_upate(
|
||||||
mut cam_query: Query<(&mut Transform, &PhosCamera, &mut PhosOrbitCamera, &CameraBounds)>,
|
cam_query: Single<(&mut Transform, &PhosCamera, &mut PhosOrbitCamera, &CameraBounds)>,
|
||||||
mut wheel: EventReader<MouseWheel>,
|
mut wheel: MessageReader<MouseWheel>,
|
||||||
mut mouse_motion: EventReader<MouseMotion>,
|
mut mouse_motion: MessageReader<MouseMotion>,
|
||||||
mouse: Res<ButtonInput<MouseButton>>,
|
mouse: Res<ButtonInput<MouseButton>>,
|
||||||
mut window_query: Query<&mut Window, With<PrimaryWindow>>,
|
mut cursor_options: Single<&mut CursorOptions, With<PrimaryWindow>>,
|
||||||
key: Res<ButtonInput<KeyCode>>,
|
key: Res<ButtonInput<KeyCode>>,
|
||||||
time: Res<Time>,
|
time: Res<Time>,
|
||||||
map: Res<Map>,
|
map: Res<Map>,
|
||||||
#[cfg(debug_assertions)] mut gizmos: Gizmos,
|
#[cfg(debug_assertions)] mut gizmos: Gizmos,
|
||||||
) {
|
) {
|
||||||
let (mut transform, config, mut orbit, bounds) = cam_query.single_mut();
|
let (mut transform, config, mut orbit, bounds) = cam_query.into_inner();
|
||||||
let mut window = window_query.single_mut();
|
|
||||||
|
|
||||||
let target = orbit.target;
|
let target = orbit.target;
|
||||||
let mut cam_pos = target;
|
let mut cam_pos = target;
|
||||||
@@ -93,11 +92,11 @@ fn orbit_camera_upate(
|
|||||||
orbit.forward = rot_x * rot_y * orbit.forward;
|
orbit.forward = rot_x * rot_y * orbit.forward;
|
||||||
// orbit.forward.y = orbit.forward.y.clamp(-0.9, 0.0);
|
// orbit.forward.y = orbit.forward.y.clamp(-0.9, 0.0);
|
||||||
orbit.forward = orbit.forward.normalize();
|
orbit.forward = orbit.forward.normalize();
|
||||||
window.cursor_options.grab_mode = CursorGrabMode::Locked;
|
cursor_options.grab_mode = CursorGrabMode::Locked;
|
||||||
window.cursor_options.visible = false;
|
cursor_options.visible = false;
|
||||||
} else {
|
} else {
|
||||||
window.cursor_options.grab_mode = CursorGrabMode::None;
|
cursor_options.grab_mode = CursorGrabMode::None;
|
||||||
window.cursor_options.visible = true;
|
cursor_options.visible = true;
|
||||||
}
|
}
|
||||||
if key.pressed(KeyCode::KeyE) {
|
if key.pressed(KeyCode::KeyE) {
|
||||||
let rot = Quat::from_axis_angle(Vec3::Y, f32::to_radians(config.speed) * time.delta_secs());
|
let rot = Quat::from_axis_angle(Vec3::Y, f32::to_radians(config.speed) * time.delta_secs());
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use bevy::{math::Direction3d, prelude::*};
|
use bevy::prelude::*;
|
||||||
use rayon::str;
|
use rayon::str;
|
||||||
use world_generation::{hex_utils::SHORT_DIAGONAL, prelude::Chunk};
|
use world_generation::{hex_utils::SHORT_DIAGONAL, prelude::Chunk};
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ use bevy::image::{ImageAddressMode, ImageFilterMode, ImageSamplerDescriptor};
|
|||||||
use bevy::pbr::wireframe::WireframePlugin;
|
use bevy::pbr::wireframe::WireframePlugin;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::window::PresentMode;
|
use bevy::window::PresentMode;
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
use bevy::window::WindowResolution;
|
||||||
use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
||||||
use phos::PhosGamePlugin;
|
use phos::PhosGamePlugin;
|
||||||
|
|
||||||
@@ -24,7 +26,7 @@ fn main() {
|
|||||||
title: "Phos".into(),
|
title: "Phos".into(),
|
||||||
name: Some("phos".into()),
|
name: Some("phos".into()),
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
resolution: (1920., 1080.).into(),
|
resolution: WindowResolution::new(1920, 1080),
|
||||||
present_mode: PresentMode::AutoNoVsync,
|
present_mode: PresentMode::AutoNoVsync,
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
mode: bevy::window::WindowMode::BorderlessFullscreen,
|
mode: bevy::window::WindowMode::BorderlessFullscreen,
|
||||||
@@ -46,7 +48,7 @@ fn main() {
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
WorldInspectorPlugin::new(),
|
WorldInspectorPlugin::new(),
|
||||||
WireframePlugin,
|
WireframePlugin::default(),
|
||||||
PhosGamePlugin,
|
PhosGamePlugin,
|
||||||
))
|
))
|
||||||
.run();
|
.run();
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
use bevy::ecs::world::CommandQueue;
|
use bevy::ecs::world::CommandQueue;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::tasks::*;
|
use bevy::tasks::*;
|
||||||
use bevy::utils::futures;
|
|
||||||
use bevy_rapier3d::geometry::Collider;
|
use bevy_rapier3d::geometry::Collider;
|
||||||
use bevy_rapier3d::geometry::TriMeshFlags;
|
use bevy_rapier3d::geometry::TriMeshFlags;
|
||||||
use shared::events::ChunkModifiedEvent;
|
use shared::events::ChunkModifiedEvent;
|
||||||
@@ -20,8 +19,8 @@ pub struct ChunkRebuildPlugin;
|
|||||||
impl Plugin for ChunkRebuildPlugin {
|
impl Plugin for ChunkRebuildPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.init_resource::<PhosChunkRegistry>();
|
app.init_resource::<PhosChunkRegistry>();
|
||||||
app.add_event::<ChunkModifiedEvent>();
|
app.add_message::<ChunkModifiedEvent>();
|
||||||
app.add_event::<TileModifiedEvent>();
|
app.add_message::<TileModifiedEvent>();
|
||||||
app.add_systems(PreUpdate, chunk_rebuilder.run_if(in_state(GeneratorState::Idle)));
|
app.add_systems(PreUpdate, chunk_rebuilder.run_if(in_state(GeneratorState::Idle)));
|
||||||
app.add_systems(PostUpdate, collider_task_resolver);
|
app.add_systems(PostUpdate, collider_task_resolver);
|
||||||
}
|
}
|
||||||
@@ -55,7 +54,8 @@ fn chunk_rebuilder(
|
|||||||
collider_data.0,
|
collider_data.0,
|
||||||
collider_data.1,
|
collider_data.1,
|
||||||
TriMeshFlags::DELETE_DUPLICATE_TRIANGLES,
|
TriMeshFlags::DELETE_DUPLICATE_TRIANGLES,
|
||||||
);
|
)
|
||||||
|
.expect("Failed to build chunk mesh");
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
drop(trimesh_span);
|
drop(trimesh_span);
|
||||||
queue.push(move |world: &mut World| {
|
queue.push(move |world: &mut World| {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
use bevy::log::*;
|
use bevy::log::*;
|
||||||
use bevy::{
|
use bevy::{
|
||||||
pbr::{ExtendedMaterial, NotShadowCaster},
|
light::NotShadowCaster,
|
||||||
|
pbr::ExtendedMaterial,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
render::render_resource::{ColorTargetState, FragmentState, RenderPipelineDescriptor},
|
render::render_resource::{ColorTargetState, FragmentState, RenderPipelineDescriptor},
|
||||||
};
|
};
|
||||||
@@ -51,10 +52,7 @@ impl Plugin for MapInitPlugin {
|
|||||||
ChunkRebuildPlugin,
|
ChunkRebuildPlugin,
|
||||||
// TerraFormingTestPlugin,
|
// TerraFormingTestPlugin,
|
||||||
MaterialPlugin::<ExtendedMaterial<StandardMaterial, ChunkMaterial>>::default(),
|
MaterialPlugin::<ExtendedMaterial<StandardMaterial, ChunkMaterial>>::default(),
|
||||||
MaterialPlugin::<ExtendedMaterial<StandardMaterial, WaterMaterial>> {
|
MaterialPlugin::<ExtendedMaterial<StandardMaterial, WaterMaterial>> { ..Default::default() },
|
||||||
prepass_enabled: false,
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
));
|
));
|
||||||
|
|
||||||
app.configure_loading_state(
|
app.configure_loading_state(
|
||||||
@@ -78,7 +76,7 @@ impl Plugin for MapInitPlugin {
|
|||||||
app.add_systems(Update, despawn_map.run_if(in_state(GeneratorState::Regenerate)));
|
app.add_systems(Update, despawn_map.run_if(in_state(GeneratorState::Regenerate)));
|
||||||
app.add_systems(
|
app.add_systems(
|
||||||
Update,
|
Update,
|
||||||
spawn_map.run_if(in_state(AssetLoadState::LoadComplete).and_then(in_state(GeneratorState::SpawnMap))),
|
spawn_map.run_if(in_state(AssetLoadState::LoadComplete).and(in_state(GeneratorState::SpawnMap))),
|
||||||
);
|
);
|
||||||
|
|
||||||
app.insert_resource(TileManager::default());
|
app.insert_resource(TileManager::default());
|
||||||
|
|||||||
@@ -53,10 +53,9 @@ impl Default for RenderDistanceVisibility {
|
|||||||
|
|
||||||
fn render_distance_system(
|
fn render_distance_system(
|
||||||
mut objects: Query<(&Transform, &mut Visibility, &RenderDistanceVisibility)>,
|
mut objects: Query<(&Transform, &mut Visibility, &RenderDistanceVisibility)>,
|
||||||
camera_query: Query<&Transform, With<MainCamera>>,
|
camera: Single<&Transform, With<MainCamera>>,
|
||||||
settings: Res<RenderDistanceSettings>,
|
settings: Res<RenderDistanceSettings>,
|
||||||
) {
|
) {
|
||||||
let camera = camera_query.single();
|
|
||||||
let cam_pos = Vec3::new(camera.translation.x, 0.0, camera.translation.z);
|
let cam_pos = Vec3::new(camera.translation.x, 0.0, camera.translation.z);
|
||||||
for (t, mut vis, r) in objects.iter_mut() {
|
for (t, mut vis, r) in objects.iter_mut() {
|
||||||
let dist = (cam_pos - (t.translation + r.offset)).length();
|
let dist = (cam_pos - (t.translation + r.offset)).length();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use bevy::{prelude::*, utils::hashbrown::HashSet, window::PrimaryWindow};
|
use bevy::{platform::collections::HashSet, prelude::*, window::PrimaryWindow};
|
||||||
use bevy_rapier3d::{pipeline::QueryFilter, plugin::RapierContext};
|
use bevy_rapier3d::{pipeline::QueryFilter, plugin::RapierContext};
|
||||||
use shared::{
|
use shared::{
|
||||||
events::{ChunkModifiedEvent, TileModifiedEvent},
|
events::{ChunkModifiedEvent, TileModifiedEvent},
|
||||||
@@ -31,8 +31,8 @@ fn deform(
|
|||||||
mut heightmap: ResMut<Map>,
|
mut heightmap: ResMut<Map>,
|
||||||
chunks: Res<PhosChunkRegistry>,
|
chunks: Res<PhosChunkRegistry>,
|
||||||
tile_under_cursor: Res<TileUnderCursor>,
|
tile_under_cursor: Res<TileUnderCursor>,
|
||||||
mut chunk_modified: EventWriter<ChunkModifiedEvent>,
|
mut chunk_modified: MessageWriter<ChunkModifiedEvent>,
|
||||||
mut tile_modified: EventWriter<TileModifiedEvent>,
|
mut tile_modified: MessageWriter<TileModifiedEvent>,
|
||||||
) {
|
) {
|
||||||
let mut multi = 0.;
|
let mut multi = 0.;
|
||||||
if mouse.just_pressed(MouseButton::Left) {
|
if mouse.just_pressed(MouseButton::Left) {
|
||||||
@@ -53,11 +53,11 @@ fn deform(
|
|||||||
for (tile, height) in modified_tiles {
|
for (tile, height) in modified_tiles {
|
||||||
let chunk = tile.to_chunk_index(heightmap.width);
|
let chunk = tile.to_chunk_index(heightmap.width);
|
||||||
if !chunk_set.contains(&chunk) {
|
if !chunk_set.contains(&chunk) {
|
||||||
chunk_modified.send(ChunkModifiedEvent { index: chunk });
|
chunk_modified.write(ChunkModifiedEvent { index: chunk });
|
||||||
chunk_set.insert(chunk);
|
chunk_set.insert(chunk);
|
||||||
commands.entity(chunks.chunks[chunk]).insert(RebuildChunk);
|
commands.entity(chunks.chunks[chunk]).insert(RebuildChunk);
|
||||||
}
|
}
|
||||||
tile_modified.send(TileModifiedEvent::HeightChanged(tile, height));
|
tile_modified.write(TileModifiedEvent::HeightChanged(tile, height));
|
||||||
}
|
}
|
||||||
// commands.entity(e).insert(RebuildChunk);
|
// commands.entity(e).insert(RebuildChunk);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,17 +5,16 @@ use crate::ui::build_ui::BuildUIPlugin;
|
|||||||
use crate::utlis::editor_plugin::EditorPlugin;
|
use crate::utlis::editor_plugin::EditorPlugin;
|
||||||
use crate::utlis::tile_selection_plugin::TileSelectionPlugin;
|
use crate::utlis::tile_selection_plugin::TileSelectionPlugin;
|
||||||
use crate::{camera_system::camera_plugin::PhosCameraPlugin, utlis::debug_plugin::DebugPlugin};
|
use crate::{camera_system::camera_plugin::PhosCameraPlugin, utlis::debug_plugin::DebugPlugin};
|
||||||
use bevy::{
|
use bevy::diagnostic::{EntityCountDiagnosticsPlugin, FrameTimeDiagnosticsPlugin};
|
||||||
pbr::{wireframe::WireframeConfig, CascadeShadowConfig},
|
use bevy::light::CascadeShadowConfig;
|
||||||
prelude::*,
|
use bevy::{pbr::wireframe::WireframeConfig, prelude::*};
|
||||||
};
|
|
||||||
use bevy_asset_loader::prelude::*;
|
use bevy_asset_loader::prelude::*;
|
||||||
use bevy_rapier3d::dynamics::{Ccd, RigidBody, Velocity};
|
use bevy_rapier3d::dynamics::{Ccd, RigidBody, Velocity};
|
||||||
use bevy_rapier3d::geometry::Collider;
|
use bevy_rapier3d::geometry::Collider;
|
||||||
use bevy_rapier3d::plugin::{NoUserData, RapierPhysicsPlugin};
|
use bevy_rapier3d::plugin::{NoUserData, RapierPhysicsPlugin};
|
||||||
use buildings::BuildingPugin;
|
use buildings::BuildingPugin;
|
||||||
// use iyes_perf_ui::prelude::*;
|
// use iyes_perf_ui::prelude::*;
|
||||||
use shared::animation_plugin::SimpleAnimationPlugin;
|
// use shared::animation_plugin::SimpleAnimationPlugin;
|
||||||
use shared::sets::GameplaySet;
|
use shared::sets::GameplaySet;
|
||||||
use shared::states::{GameplayState, MenuState};
|
use shared::states::{GameplayState, MenuState};
|
||||||
use shared::{despawn::DespawnPuglin, states::AssetLoadState};
|
use shared::{despawn::DespawnPuglin, states::AssetLoadState};
|
||||||
@@ -40,7 +39,7 @@ impl Plugin for PhosGamePlugin {
|
|||||||
RenderDistancePlugin,
|
RenderDistancePlugin,
|
||||||
BuildingPugin,
|
BuildingPugin,
|
||||||
BuildUIPlugin,
|
BuildUIPlugin,
|
||||||
SimpleAnimationPlugin,
|
// SimpleAnimationPlugin,
|
||||||
UnitsPlugin,
|
UnitsPlugin,
|
||||||
DespawnPuglin,
|
DespawnPuglin,
|
||||||
TileSelectionPlugin,
|
TileSelectionPlugin,
|
||||||
@@ -59,8 +58,8 @@ impl Plugin for PhosGamePlugin {
|
|||||||
app.add_systems(Update, spawn_sphere);
|
app.add_systems(Update, spawn_sphere);
|
||||||
|
|
||||||
//Perf UI
|
//Perf UI
|
||||||
app.add_plugins(bevy::diagnostic::FrameTimeDiagnosticsPlugin)
|
app.add_plugins(FrameTimeDiagnosticsPlugin::default())
|
||||||
.add_plugins(bevy::diagnostic::EntityCountDiagnosticsPlugin)
|
.add_plugins(EntityCountDiagnosticsPlugin::default())
|
||||||
.add_plugins(bevy::diagnostic::SystemInformationDiagnosticsPlugin);
|
.add_plugins(bevy::diagnostic::SystemInformationDiagnosticsPlugin);
|
||||||
// .add_plugins(PerfUiPlugin);
|
// .add_plugins(PerfUiPlugin);
|
||||||
|
|
||||||
@@ -137,21 +136,20 @@ struct SphereMat(Handle<StandardMaterial>);
|
|||||||
|
|
||||||
fn spawn_sphere(
|
fn spawn_sphere(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
cam: Query<&Transform, With<PhosCamera>>,
|
cam: Single<&Transform, With<PhosCamera>>,
|
||||||
keyboard_input: Res<ButtonInput<KeyCode>>,
|
keyboard_input: Res<ButtonInput<KeyCode>>,
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
mat: Res<SphereMat>,
|
mat: Res<SphereMat>,
|
||||||
) {
|
) {
|
||||||
if keyboard_input.just_pressed(KeyCode::KeyF) {
|
if keyboard_input.just_pressed(KeyCode::KeyF) {
|
||||||
let cam_transform = cam.single();
|
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Mesh3d(meshes.add(Sphere::new(0.3))),
|
Mesh3d(meshes.add(Sphere::new(0.3))),
|
||||||
MeshMaterial3d(mat.0.clone()),
|
MeshMaterial3d(mat.0.clone()),
|
||||||
Transform::from_translation(cam_transform.translation),
|
Transform::from_translation(cam.translation),
|
||||||
Collider::ball(0.3),
|
Collider::ball(0.3),
|
||||||
RigidBody::Dynamic,
|
RigidBody::Dynamic,
|
||||||
Ccd::enabled(),
|
Ccd::enabled(),
|
||||||
Velocity::linear(cam_transform.forward() * 50.),
|
Velocity::linear(cam.forward() * 50.),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ use bevy::asset::{Asset, Handle};
|
|||||||
use bevy::image::Image;
|
use bevy::image::Image;
|
||||||
use bevy::pbr::{Material, MaterialExtension};
|
use bevy::pbr::{Material, MaterialExtension};
|
||||||
use bevy::reflect::TypePath;
|
use bevy::reflect::TypePath;
|
||||||
use bevy::render::mesh::{MeshVertexAttribute, MeshVertexBufferLayoutRef};
|
use bevy::render::render_resource::AsBindGroup;
|
||||||
use bevy::render::render_resource::{AsBindGroup, ShaderRef};
|
use bevy::shader::ShaderRef;
|
||||||
use world_generation::consts::{ATTRIBUTE_PACKED_VERTEX_DATA, ATTRIBUTE_VERTEX_HEIGHT};
|
use world_generation::consts::{ATTRIBUTE_PACKED_VERTEX_DATA, ATTRIBUTE_VERTEX_HEIGHT};
|
||||||
|
|
||||||
#[derive(Asset, TypePath, AsBindGroup, Debug, Clone)]
|
#[derive(Asset, TypePath, AsBindGroup, Debug, Clone)]
|
||||||
@@ -48,11 +48,11 @@ impl Material for PackedChunkMaterial {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
fn specialize(
|
fn specialize(
|
||||||
_pipeline: &bevy::pbr::MaterialPipeline<Self>,
|
pipeline: &bevy::pbr::MaterialPipeline,
|
||||||
descriptor: &mut bevy::render::render_resource::RenderPipelineDescriptor,
|
descriptor: &mut bevy::render::render_resource::RenderPipelineDescriptor,
|
||||||
layout: &MeshVertexBufferLayoutRef,
|
layout: &bevy::mesh::MeshVertexBufferLayoutRef,
|
||||||
_key: bevy::pbr::MaterialPipelineKey<Self>,
|
key: bevy::pbr::MaterialPipelineKey<Self>,
|
||||||
) -> Result<(), bevy::render::render_resource::SpecializedMeshPipelineError> {
|
) -> bevy::ecs::error::Result<(), bevy::render::render_resource::SpecializedMeshPipelineError> {
|
||||||
let vertex_layout = layout.0.get_layout(&[
|
let vertex_layout = layout.0.get_layout(&[
|
||||||
// Mesh::ATTRIBUTE_POSITION.at_shader_location(0),
|
// Mesh::ATTRIBUTE_POSITION.at_shader_location(0),
|
||||||
// Mesh::ATTRIBUTE_UV_0.at_shader_location(1),
|
// Mesh::ATTRIBUTE_UV_0.at_shader_location(1),
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ use bevy::math::VectorSpace;
|
|||||||
use bevy::pbr::MaterialExtension;
|
use bevy::pbr::MaterialExtension;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::reflect::Reflect;
|
use bevy::reflect::Reflect;
|
||||||
use bevy::render::render_resource::{AsBindGroup, ShaderRef, ShaderType};
|
use bevy::render::render_resource::{AsBindGroup, ShaderType};
|
||||||
|
use bevy::shader::ShaderRef;
|
||||||
|
|
||||||
#[derive(Asset, Reflect, AsBindGroup, Debug, Clone, Default)]
|
#[derive(Asset, Reflect, AsBindGroup, Debug, Clone, Default)]
|
||||||
pub struct WaterMaterial {
|
pub struct WaterMaterial {
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
use bevy::{
|
use bevy::prelude::*;
|
||||||
prelude::*,
|
|
||||||
render::{camera::RenderTarget, view::RenderLayers},
|
|
||||||
};
|
|
||||||
use shared::{states::AssetLoadState, tags::MainCamera};
|
use shared::{states::AssetLoadState, tags::MainCamera};
|
||||||
pub struct BuildUIPlugin;
|
pub struct BuildUIPlugin;
|
||||||
|
|
||||||
@@ -13,7 +10,7 @@ impl Plugin for BuildUIPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn setup_cameras(mut commands: Commands) {
|
fn setup_cameras(mut commands: Commands) {
|
||||||
commands.spawn((Camera2d, IsDefaultUiCamera, UiBoxShadowSamples(6)));
|
commands.spawn((Camera2d, IsDefaultUiCamera));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_ui(mut commands: Commands) {
|
fn spawn_ui(mut commands: Commands) {
|
||||||
@@ -25,7 +22,7 @@ fn spawn_ui(mut commands: Commands) {
|
|||||||
align_items: AlignItems::End,
|
align_items: AlignItems::End,
|
||||||
..default()
|
..default()
|
||||||
},))
|
},))
|
||||||
.insert(PickingBehavior::IGNORE)
|
// .insert(PickingBehavior::IGNORE)
|
||||||
.with_children(|parent| {
|
.with_children(|parent| {
|
||||||
parent.spawn((
|
parent.spawn((
|
||||||
Node {
|
Node {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use bevy::{
|
|||||||
asset::Assets,
|
asset::Assets,
|
||||||
ecs::system::Res,
|
ecs::system::Res,
|
||||||
math::{IVec2, UVec2, Vec3},
|
math::{IVec2, UVec2, Vec3},
|
||||||
render::mesh::Mesh,
|
mesh::Mesh,
|
||||||
};
|
};
|
||||||
use bevy_rapier3d::geometry::{Collider, TriMeshFlags};
|
use bevy_rapier3d::geometry::{Collider, TriMeshFlags};
|
||||||
use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator};
|
use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator};
|
||||||
@@ -87,7 +87,8 @@ pub fn prepare_chunk_mesh_with_collider(
|
|||||||
{
|
{
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
let _collider_span = info_span!("Create Collider Trimesh").entered();
|
let _collider_span = info_span!("Create Collider Trimesh").entered();
|
||||||
collider = Collider::trimesh_with_flags(col_verts, col_indicies, TriMeshFlags::DELETE_DUPLICATE_TRIANGLES);
|
collider = Collider::trimesh_with_flags(col_verts, col_indicies, TriMeshFlags::DELETE_DUPLICATE_TRIANGLES)
|
||||||
|
.expect("Failed to generate chunk collision mesh");
|
||||||
}
|
}
|
||||||
return (chunk_mesh, water_mesh, collider, pos, index);
|
return (chunk_mesh, water_mesh, collider, pos, index);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ impl Plugin for DebugPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
struct Shape(pub Polyline3d<7>);
|
struct Shape(pub Polyline3d);
|
||||||
|
|
||||||
#[derive(States, Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(States, Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum DebugState {
|
pub enum DebugState {
|
||||||
@@ -87,8 +87,8 @@ fn show_water_corners(pos: Vec3, gizmos: &mut Gizmos) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn camera_debug(mut cam_query: Query<(&PhosCamera, &PhosOrbitCamera)>, mut gizmos: Gizmos) {
|
fn camera_debug(mut cam_query: Single<(&PhosCamera, &PhosOrbitCamera)>, mut gizmos: Gizmos) {
|
||||||
let (config, orbit) = cam_query.single();
|
let (config, orbit) = cam_query.into_inner();
|
||||||
|
|
||||||
gizmos.sphere(orbit.target, 0.3, LinearRgba::RED);
|
gizmos.sphere(orbit.target, 0.3, LinearRgba::RED);
|
||||||
let cam_proxy = orbit.target - (orbit.forward * 10.0);
|
let cam_proxy = orbit.target - (orbit.forward * 10.0);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use bevy::{prelude::*, render::render_asset::RenderAssetUsages};
|
use bevy::asset::RenderAssetUsages;
|
||||||
|
use bevy::prelude::*;
|
||||||
use bevy_inspector_egui::bevy_egui::EguiContexts;
|
use bevy_inspector_egui::bevy_egui::EguiContexts;
|
||||||
use bevy_inspector_egui::egui::{self};
|
use bevy_inspector_egui::egui::{self};
|
||||||
use image::{ImageBuffer, Rgba};
|
use image::{ImageBuffer, Rgba};
|
||||||
@@ -61,7 +62,7 @@ enum MapDisplayType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn asset_reloaded(
|
fn asset_reloaded(
|
||||||
mut asset_events: EventReader<AssetEvent<BiomeAsset>>,
|
mut asset_events: MessageReader<AssetEvent<BiomeAsset>>,
|
||||||
mut biomes: ResMut<Assets<BiomeAsset>>,
|
mut biomes: ResMut<Assets<BiomeAsset>>,
|
||||||
biome_painter: Res<BiomePainterAsset>,
|
biome_painter: Res<BiomePainterAsset>,
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
@@ -79,55 +80,55 @@ fn asset_reloaded(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_map_ui(
|
// fn render_map_ui(
|
||||||
image: Res<MapImage>,
|
// image: Res<MapImage>,
|
||||||
heightmap: Res<Map>,
|
// heightmap: Res<Map>,
|
||||||
biome_map: Res<BiomeMap>,
|
// biome_map: Res<BiomeMap>,
|
||||||
mut contexts: EguiContexts,
|
// mut contexts: EguiContexts,
|
||||||
mut state: ResMut<UIState>,
|
// mut state: ResMut<UIState>,
|
||||||
) {
|
// ) {
|
||||||
let id = contexts.add_image(image.0.clone_weak());
|
// let id = contexts.add_image(image.0.clone());
|
||||||
|
|
||||||
let mut map_type = state.target_map_type;
|
// let mut map_type = state.target_map_type;
|
||||||
let ctx = contexts.ctx_mut();
|
// let ctx = contexts.ctx_mut();
|
||||||
egui::Window::new("Map").open(&mut state.is_open).show(ctx, |ui| {
|
// egui::Window::new("Map").open(&mut state.is_open).show(ctx, |ui| {
|
||||||
ui.label("Map Test");
|
// ui.label("Map Test");
|
||||||
egui::ComboBox::from_label("Display Type")
|
// egui::ComboBox::from_label("Display Type")
|
||||||
.selected_text(format!("{:?}", map_type))
|
// .selected_text(format!("{:?}", map_type))
|
||||||
.show_ui(ui, |ui| {
|
// .show_ui(ui, |ui| {
|
||||||
ui.selectable_value(&mut map_type, MapDisplayType::HeightMap, "Heightmap");
|
// ui.selectable_value(&mut map_type, MapDisplayType::HeightMap, "Heightmap");
|
||||||
ui.selectable_value(&mut map_type, MapDisplayType::Biomes, "Biomes");
|
// ui.selectable_value(&mut map_type, MapDisplayType::Biomes, "Biomes");
|
||||||
ui.selectable_value(&mut map_type, MapDisplayType::BiomeNoise, "Biome Noise");
|
// ui.selectable_value(&mut map_type, MapDisplayType::BiomeNoise, "Biome Noise");
|
||||||
ui.selectable_value(
|
// ui.selectable_value(
|
||||||
&mut map_type,
|
// &mut map_type,
|
||||||
MapDisplayType::BiomeNoiseTemp,
|
// MapDisplayType::BiomeNoiseTemp,
|
||||||
"Biome Noise: Tempurature",
|
// "Biome Noise: Tempurature",
|
||||||
);
|
// );
|
||||||
ui.selectable_value(
|
// ui.selectable_value(
|
||||||
&mut map_type,
|
// &mut map_type,
|
||||||
MapDisplayType::BiomeNoiseContinent,
|
// MapDisplayType::BiomeNoiseContinent,
|
||||||
"Biome Noise: Continent",
|
// "Biome Noise: Continent",
|
||||||
);
|
// );
|
||||||
ui.selectable_value(
|
// ui.selectable_value(
|
||||||
&mut map_type,
|
// &mut map_type,
|
||||||
MapDisplayType::BiomeNoiseMoisture,
|
// MapDisplayType::BiomeNoiseMoisture,
|
||||||
"Biome Noise: Moisture",
|
// "Biome Noise: Moisture",
|
||||||
);
|
// );
|
||||||
});
|
// });
|
||||||
|
|
||||||
ui.add(egui::widgets::Image::new(egui::load::SizedTexture::new(
|
// ui.add(egui::widgets::Image::new(egui::load::SizedTexture::new(
|
||||||
id,
|
// id,
|
||||||
[512.0, 512.0],
|
// [512.0, 512.0],
|
||||||
)));
|
// )));
|
||||||
|
|
||||||
if ui.button("Save Image").clicked() {
|
// if ui.button("Save Image").clicked() {
|
||||||
let img = get_map_image(&heightmap, &biome_map, map_type);
|
// let img = get_map_image(&heightmap, &biome_map, map_type);
|
||||||
_ = img.save(format!("{:?}.png", map_type));
|
// _ = img.save(format!("{:?}.png", map_type));
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
state.target_map_type = map_type;
|
// state.target_map_type = map_type;
|
||||||
}
|
// }
|
||||||
|
|
||||||
fn update_map_render(
|
fn update_map_render(
|
||||||
mut state: ResMut<UIState>,
|
mut state: ResMut<UIState>,
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
use bevy::{prelude::*, window::PrimaryWindow};
|
use bevy::{prelude::*, window::PrimaryWindow};
|
||||||
use bevy_rapier3d::{
|
use bevy_rapier3d::{plugin::RapierContext, prelude::QueryFilter};
|
||||||
plugin::{RapierContext, ReadDefaultRapierContext},
|
|
||||||
prelude::QueryFilter,
|
|
||||||
};
|
|
||||||
use shared::{
|
use shared::{
|
||||||
resources::{TileContact, TileUnderCursor},
|
resources::{TileContact, TileUnderCursor},
|
||||||
tags::MainCamera,
|
tags::MainCamera,
|
||||||
@@ -21,20 +18,14 @@ impl Plugin for TileSelectionPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn update_tile_under_cursor(
|
fn update_tile_under_cursor(
|
||||||
cam_query: Query<(&GlobalTransform, &Camera), With<MainCamera>>,
|
cam_query: Single<(&GlobalTransform, &Camera), With<MainCamera>>,
|
||||||
window: Query<&Window, With<PrimaryWindow>>,
|
window: Single<&Window, With<PrimaryWindow>>,
|
||||||
rapier_context: ReadDefaultRapierContext,
|
// rapier_context: RapierContext,
|
||||||
map: Res<Map>,
|
map: Res<Map>,
|
||||||
mut tile_under_cursor: ResMut<TileUnderCursor>,
|
mut tile_under_cursor: ResMut<TileUnderCursor>,
|
||||||
) {
|
) {
|
||||||
let win_r = window.get_single();
|
let (cam_transform, camera) = cam_query.into_inner();
|
||||||
if win_r.is_err() {
|
let Some(cursor_pos) = window.cursor_position() else {
|
||||||
return;
|
|
||||||
}
|
|
||||||
let win = win_r.unwrap();
|
|
||||||
|
|
||||||
let (cam_transform, camera) = cam_query.single();
|
|
||||||
let Some(cursor_pos) = win.cursor_position() else {
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -42,29 +33,29 @@ fn update_tile_under_cursor(
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let collision = rapier_context.cast_ray(
|
// let collision = rapier_context.cast_ray(
|
||||||
cam_ray.origin,
|
// cam_ray.origin,
|
||||||
cam_ray.direction.into(),
|
// cam_ray.direction.into(),
|
||||||
500.,
|
// 500.,
|
||||||
true,
|
// true,
|
||||||
QueryFilter::only_fixed(),
|
// QueryFilter::only_fixed(),
|
||||||
);
|
// );
|
||||||
|
|
||||||
if let Some((_e, dist)) = collision {
|
// if let Some((_e, dist)) = collision {
|
||||||
let contact_point = cam_ray.get_point(dist);
|
// let contact_point = cam_ray.get_point(dist);
|
||||||
let contact_coord = HexCoord::from_world_pos(contact_point);
|
// let contact_coord = HexCoord::from_world_pos(contact_point);
|
||||||
//todo: handle correct tile detection when contacting a tile from the side
|
// //todo: handle correct tile detection when contacting a tile from the side
|
||||||
if !map.is_in_bounds(&contact_coord) {
|
// if !map.is_in_bounds(&contact_coord) {
|
||||||
tile_under_cursor.0 = None;
|
// tile_under_cursor.0 = None;
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
let surface = map.sample_height(&contact_coord);
|
// let surface = map.sample_height(&contact_coord);
|
||||||
tile_under_cursor.0 = Some(TileContact::new(
|
// tile_under_cursor.0 = Some(TileContact::new(
|
||||||
contact_coord,
|
// contact_coord,
|
||||||
contact_point,
|
// contact_point,
|
||||||
contact_coord.to_world(surface),
|
// contact_coord.to_world(surface),
|
||||||
));
|
// ));
|
||||||
} else {
|
// } else {
|
||||||
tile_under_cursor.0 = None;
|
// tile_under_cursor.0 = None;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.16.0"
|
bevy = "0.18.0"
|
||||||
world_generation = { path = "../../engine/world_generation" }
|
world_generation = { path = "../../engine/world_generation" }
|
||||||
shared = { path = "../shared" }
|
shared = { path = "../shared" }
|
||||||
serde = { version = "1.0.204", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
asset_loader = { path = "../../engine/asset_loader" }
|
asset_loader = { path = "../../engine/asset_loader" }
|
||||||
serde_json = "1.0.120"
|
serde_json = "1.0.149"
|
||||||
ron = "0.8.1"
|
ron = "0.12.0"
|
||||||
bevy_asset_loader = { version = "0.23.0-rc.3", features = [
|
bevy_asset_loader = { version = "0.25.0", features = [
|
||||||
"standard_dynamic_assets",
|
"standard_dynamic_assets",
|
||||||
"3d",
|
"3d",
|
||||||
] }
|
] }
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ edition = "2021"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.16.0"
|
bevy = "0.18.0"
|
||||||
serde = { version = "1.0.204", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
world_generation = { path = "../../engine/world_generation" }
|
world_generation = { path = "../../engine/world_generation" }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ fn despawn_at(mut commands: Commands, time: Res<Time>, entities: Query<(Entity,
|
|||||||
fn despawn_after(mut commands: Commands, mut entities: Query<(&mut DespawnAfter, Entity)>, time: Res<Time>) {
|
fn despawn_after(mut commands: Commands, mut entities: Query<(&mut DespawnAfter, Entity)>, time: Res<Time>) {
|
||||||
for (mut after, entity) in &mut entities.iter_mut() {
|
for (mut after, entity) in &mut entities.iter_mut() {
|
||||||
after.0.tick(time.delta());
|
after.0.tick(time.delta());
|
||||||
if after.0.finished() {
|
if after.0.is_finished() {
|
||||||
commands.entity(entity).despawn();
|
commands.entity(entity).despawn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use world_generation::hex_utils::*;
|
use world_generation::hex_utils::*;
|
||||||
|
|
||||||
#[derive(Event)]
|
#[derive(Message)]
|
||||||
pub enum TileModifiedEvent {
|
pub enum TileModifiedEvent {
|
||||||
HeightChanged(HexCoord, f32),
|
HeightChanged(HexCoord, f32),
|
||||||
TypeChanged(HexCoord, usize),
|
TypeChanged(HexCoord, usize),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Event)]
|
#[derive(Message)]
|
||||||
pub struct ChunkModifiedEvent {
|
pub struct ChunkModifiedEvent {
|
||||||
pub index: usize,
|
pub index: usize,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ pub mod resources;
|
|||||||
pub mod sets;
|
pub mod sets;
|
||||||
pub mod states;
|
pub mod states;
|
||||||
pub mod tags;
|
pub mod tags;
|
||||||
pub mod prefab_defination;
|
// pub mod prefab_defination;
|
||||||
pub mod component_defination;
|
// pub mod animation_plugin;
|
||||||
pub mod animation_plugin;
|
// pub mod component_defination;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub enum Tier {
|
pub enum Tier {
|
||||||
|
|||||||
@@ -4,21 +4,21 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.16.0"
|
bevy = "0.18.0"
|
||||||
world_generation = { path = "../../engine/world_generation" }
|
world_generation = { path = "../../engine/world_generation" }
|
||||||
shared = { path = "../shared" }
|
shared = { path = "../shared" }
|
||||||
bevy_rapier3d = "0.29.0"
|
bevy_rapier3d = "0.33.0"
|
||||||
serde = { version = "1.0.204", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
asset_loader = { path = "../../engine/asset_loader" }
|
asset_loader = { path = "../../engine/asset_loader" }
|
||||||
serde_json = "1.0.120"
|
serde_json = "1.0.149"
|
||||||
ron = "0.8.1"
|
ron = "0.12.0"
|
||||||
bevy_asset_loader = { version = "0.23.0-rc.3", features = [
|
bevy_asset_loader = { version = "0.25.0", features = [
|
||||||
"standard_dynamic_assets",
|
"standard_dynamic_assets",
|
||||||
"3d",
|
"3d",
|
||||||
] }
|
] }
|
||||||
quadtree_rs = "0.1.3"
|
quadtree_rs = "0.1.3"
|
||||||
pathfinding = "4.11.0"
|
pathfinding = "4.14.0"
|
||||||
ordered-float = "4.3.0"
|
ordered-float = "5.1.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
tracing = ["bevy/trace_tracy"]
|
tracing = ["bevy/trace_tracy"]
|
||||||
|
|||||||
@@ -20,13 +20,7 @@ impl UnitAsset {
|
|||||||
pub fn spawn(&self, transform: Transform) -> CommandQueue {
|
pub fn spawn(&self, transform: Transform) -> CommandQueue {
|
||||||
let mut commands = CommandQueue::default();
|
let mut commands = CommandQueue::default();
|
||||||
|
|
||||||
let bundle = (
|
let bundle = (transform, Unit);
|
||||||
PbrBundle {
|
|
||||||
transform: transform,
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
Unit,
|
|
||||||
);
|
|
||||||
let domain = self.domain.clone();
|
let domain = self.domain.clone();
|
||||||
commands.push(move |world: &mut World| {
|
commands.push(move |world: &mut World| {
|
||||||
let mut e = world.spawn(bundle);
|
let mut e = world.spawn(bundle);
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use bevy::{ecs::world::CommandQueue, prelude::*, tasks::AsyncComputeTaskPool, utils::futures};
|
use bevy::{
|
||||||
|
ecs::world::CommandQueue,
|
||||||
|
prelude::*,
|
||||||
|
tasks::{futures, AsyncComputeTaskPool},
|
||||||
|
};
|
||||||
use pathfinding::prelude::astar;
|
use pathfinding::prelude::astar;
|
||||||
use shared::{events::TileModifiedEvent, resources::TileUnderCursor, sets::GameplaySet};
|
use shared::{events::TileModifiedEvent, resources::TileUnderCursor, sets::GameplaySet};
|
||||||
use world_generation::{hex_utils::HexCoord, prelude::Map, states::GeneratorState};
|
use world_generation::{hex_utils::HexCoord, prelude::Map, states::GeneratorState};
|
||||||
@@ -41,7 +45,7 @@ fn build_navdata(mut commands: Commands, map: Res<Map>) {
|
|||||||
commands.insert_resource(nav_data);
|
commands.insert_resource(nav_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_navdata(mut tile_updates: EventReader<TileModifiedEvent>, mut nav_data: ResMut<NavData>) {
|
fn update_navdata(mut tile_updates: MessageReader<TileModifiedEvent>, mut nav_data: ResMut<NavData>) {
|
||||||
for event in tile_updates.read() {
|
for event in tile_updates.read() {
|
||||||
match event {
|
match event {
|
||||||
TileModifiedEvent::HeightChanged(coord, new_height) => {
|
TileModifiedEvent::HeightChanged(coord, new_height) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user