update to bevy 0.18
This commit is contained in:
@@ -6,15 +6,15 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
bevy = "0.16.0"
|
||||
bevy = "0.18.0"
|
||||
world_generation = { path = "../../engine/world_generation" }
|
||||
shared = { path = "../shared" }
|
||||
bevy_rapier3d = "0.29.0"
|
||||
serde = { version = "1.0.204", features = ["derive"] }
|
||||
bevy_rapier3d = "0.33.0"
|
||||
serde = { version = "1.0.228", features = ["derive"] }
|
||||
asset_loader = { path = "../../engine/asset_loader" }
|
||||
serde_json = "1.0.120"
|
||||
ron = "0.8.1"
|
||||
bevy_asset_loader = { version = "0.23.0-rc.3", features = [
|
||||
serde_json = "1.0.149"
|
||||
ron = "0.12.0"
|
||||
bevy_asset_loader = { version = "0.25.0", features = [
|
||||
"standard_dynamic_assets",
|
||||
"3d",
|
||||
] }
|
||||
|
||||
@@ -4,7 +4,7 @@ use bevy::{
|
||||
prelude::*,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use shared::{component_defination::ComponentDefination, identifiers::ResourceIdentifier, prefab_defination::*};
|
||||
use shared::identifiers::ResourceIdentifier;
|
||||
|
||||
use crate::{
|
||||
buildings::{
|
||||
@@ -32,7 +32,7 @@ pub struct BuildingAsset {
|
||||
pub health: u32,
|
||||
|
||||
pub building_type: BuildingType,
|
||||
pub components: Option<Vec<ComponentDefination>>,
|
||||
// pub components: Option<Vec<ComponentDefination>>,
|
||||
}
|
||||
|
||||
impl BuildingAsset {
|
||||
@@ -45,77 +45,78 @@ impl BuildingAsset {
|
||||
meshes: &Assets<GltfMesh>,
|
||||
nodes: &Assets<GltfNode>,
|
||||
) -> Option<Entity> {
|
||||
let base_node = &gltf.named_nodes[&self.base_mesh_path.clone().into_boxed_str()];
|
||||
if let Some(node) = nodes.get(base_node.id()) {
|
||||
if let Some(mesh_handle) = &node.mesh {
|
||||
if let Some(gltf_mesh) = meshes.get(mesh_handle.id()) {
|
||||
let (mesh, mat) = gltf_mesh.unpack();
|
||||
let mut entity = commands.spawn((
|
||||
Mesh3d(mesh),
|
||||
MeshMaterial3d(mat),
|
||||
Transform::from_translation(pos).with_rotation(rot),
|
||||
Building,
|
||||
));
|
||||
entity.with_children(|b| {
|
||||
for child in &node.children {
|
||||
let child_node = nodes.get(child.id());
|
||||
if child_node.is_none() {
|
||||
continue;
|
||||
}
|
||||
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);
|
||||
}
|
||||
return Some(entity.id());
|
||||
}
|
||||
}
|
||||
}
|
||||
return None;
|
||||
todo!("Update building spawning");
|
||||
// let base_node = &gltf.named_nodes[&self.base_mesh_path.clone().into_boxed_str()];
|
||||
// if let Some(node) = nodes.get(base_node.id()) {
|
||||
// if let Some(mesh_handle) = &node.mesh {
|
||||
// if let Some(gltf_mesh) = meshes.get(mesh_handle.id()) {
|
||||
// let (mesh, mat) = gltf_mesh.unpack();
|
||||
// let mut entity = commands.spawn((
|
||||
// Mesh3d(mesh),
|
||||
// MeshMaterial3d(mat),
|
||||
// Transform::from_translation(pos).with_rotation(rot),
|
||||
// Building,
|
||||
// ));
|
||||
// entity.with_children(|b| {
|
||||
// for child in &node.children {
|
||||
// let child_node = nodes.get(child.id());
|
||||
// if child_node.is_none() {
|
||||
// continue;
|
||||
// }
|
||||
// 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);
|
||||
// }
|
||||
// return Some(entity.id());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return None;
|
||||
}
|
||||
|
||||
fn process_node(
|
||||
&self,
|
||||
node: &GltfNode,
|
||||
meshes: &Assets<GltfMesh>,
|
||||
nodes: &Assets<GltfNode>,
|
||||
commands: &mut ChildBuilder,
|
||||
parent: &String,
|
||||
) -> Option<Entity> {
|
||||
let path = format!("{0}/{1}", parent, node.name);
|
||||
if let Some(mesh) = &node.mesh {
|
||||
if let Some(gltf_mesh) = meshes.get(mesh.id()) {
|
||||
let (mesh, mat) = gltf_mesh.unpack();
|
||||
let mut entity = commands.spawn((Mesh3d(mesh), MeshMaterial3d(mat), node.transform, Building));
|
||||
entity.with_children(|b| {
|
||||
for child in &node.children {
|
||||
let child_node = nodes.get(child.id());
|
||||
if child_node.is_none() {
|
||||
continue;
|
||||
}
|
||||
self.process_node(child_node.unwrap(), meshes, nodes, b, &path);
|
||||
}
|
||||
});
|
||||
if let Some(component) = self.get_component_def(&path) {
|
||||
component.apply(&mut entity);
|
||||
}
|
||||
return Some(entity.id());
|
||||
}
|
||||
}
|
||||
return None;
|
||||
}
|
||||
// fn process_node(
|
||||
// &self,
|
||||
// node: &GltfNode,
|
||||
// meshes: &Assets<GltfMesh>,
|
||||
// nodes: &Assets<GltfNode>,
|
||||
// commands: &mut ChildBuilder,
|
||||
// parent: &String,
|
||||
// ) -> Option<Entity> {
|
||||
// let path = format!("{0}/{1}", parent, node.name);
|
||||
// if let Some(mesh) = &node.mesh {
|
||||
// if let Some(gltf_mesh) = meshes.get(mesh.id()) {
|
||||
// let (mesh, mat) = gltf_mesh.unpack();
|
||||
// let mut entity = commands.spawn((Mesh3d(mesh), MeshMaterial3d(mat), node.transform, Building));
|
||||
// entity.with_children(|b| {
|
||||
// for child in &node.children {
|
||||
// let child_node = nodes.get(child.id());
|
||||
// if child_node.is_none() {
|
||||
// continue;
|
||||
// }
|
||||
// self.process_node(child_node.unwrap(), meshes, nodes, b, &path);
|
||||
// }
|
||||
// });
|
||||
// if let Some(component) = self.get_component_def(&path) {
|
||||
// component.apply(&mut entity);
|
||||
// }
|
||||
// return Some(entity.id());
|
||||
// }
|
||||
// }
|
||||
// return None;
|
||||
// }
|
||||
|
||||
fn get_component_def(&self, path: &String) -> Option<&ComponentDefination> {
|
||||
if let Some(components) = &self.components {
|
||||
for c in components {
|
||||
if c.path.ends_with(path) {
|
||||
return Some(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
return None;
|
||||
}
|
||||
// fn get_component_def(&self, path: &String) -> Option<&ComponentDefination> {
|
||||
// if let Some(components) = &self.components {
|
||||
// for c in components {
|
||||
// if c.path.ends_with(path) {
|
||||
// return Some(c);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return None;
|
||||
// }
|
||||
}
|
||||
|
||||
#[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,
|
||||
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(
|
||||
PreUpdate,
|
||||
@@ -155,7 +155,7 @@ fn process_build_queue(
|
||||
}
|
||||
|
||||
fn update_building_heights(
|
||||
mut tile_updates: EventReader<TileModifiedEvent>,
|
||||
mut tile_updates: MessageReader<TileModifiedEvent>,
|
||||
building_map: Res<BuildingMap>,
|
||||
mut commands: Commands,
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user