Compare commits
19 Commits
overlay-te
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| cb95db862c | |||
| 5b4e96177c | |||
| 8e2dc04a6f | |||
| 327e4b2739 | |||
| 74450bdcd3 | |||
| 2ad50f7ac8 | |||
| 9800d1fd74 | |||
| 358b88e7fe | |||
| 953650e394 | |||
| 4cfe2d9079 | |||
| 55e9b5d845 | |||
| b14f2ef99f | |||
| ea271c25d0 | |||
| 6caeb6c579 | |||
| fe98627186 | |||
| 576ea96e9b | |||
| ba7b3abc25 | |||
| 4271167752 | |||
| c5a3d1c401 |
1594
Cargo.lock
generated
1594
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -9,5 +9,5 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
serde = "1.0.204"
|
serde = "1.0.204"
|
||||||
serde_json = "1.0.120"
|
serde_json = "1.0.120"
|
||||||
bevy = "0.14.2"
|
bevy = "0.15.1"
|
||||||
ron = "0.8.1"
|
ron = "0.8.1"
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
pub mod macros;
|
pub mod macros;
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ macro_rules! create_asset_loader {
|
|||||||
|
|
||||||
type Error = String;
|
type Error = String;
|
||||||
|
|
||||||
async fn load<'a>(
|
async fn load(
|
||||||
&'a self,
|
&self,
|
||||||
reader: &'a mut Reader<'_>,
|
reader: & mut dyn bevy::asset::io::Reader,
|
||||||
_settings: &'a Self::Settings,
|
_: &Self::Settings,
|
||||||
load_context: &'a mut LoadContext<'_>,
|
load_context: &mut 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() {
|
||||||
|
|||||||
@@ -9,5 +9,5 @@ proc-macro = true
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
serde = "1.0.204"
|
serde = "1.0.204"
|
||||||
serde_json = "1.0.120"
|
serde_json = "1.0.120"
|
||||||
bevy = "0.14.2"
|
bevy = "0.15.1"
|
||||||
ron = "0.8.1"
|
ron = "0.8.1"
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ 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.14.2"
|
bevy = "0.15.1"
|
||||||
noise = "0.9.0"
|
noise = "0.9.0"
|
||||||
serde = { version = "1.0.203", features = ["derive"] }
|
serde = { version = "1.0.203", features = ["derive"] }
|
||||||
serde_json = "1.0.115"
|
serde_json = "1.0.115"
|
||||||
asset_loader = { path = "../asset_loader" }
|
asset_loader = { path = "../asset_loader" }
|
||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
bevy-inspector-egui = "0.25.0"
|
bevy-inspector-egui = "0.28.1"
|
||||||
bevy_asset_loader = { version = "0.21.0", features = [
|
bevy_asset_loader = { version = "0.22.0", features = [
|
||||||
"standard_dynamic_assets",
|
"standard_dynamic_assets",
|
||||||
"3d",
|
"3d",
|
||||||
] }
|
] }
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ pub const HEX_NORMALS: [Vec3; 6] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
pub const ATTRIBUTE_PACKED_VERTEX_DATA: MeshVertexAttribute =
|
pub const ATTRIBUTE_PACKED_VERTEX_DATA: MeshVertexAttribute =
|
||||||
MeshVertexAttribute::new("PackedVertexData", 988540817, VertexFormat::Uint32);
|
MeshVertexAttribute::new("PackedVertexData", 7, VertexFormat::Uint32);
|
||||||
pub const ATTRIBUTE_VERTEX_HEIGHT: MeshVertexAttribute =
|
pub const ATTRIBUTE_VERTEX_HEIGHT: MeshVertexAttribute =
|
||||||
MeshVertexAttribute::new("VertexHeight", 988540717, VertexFormat::Float32);
|
MeshVertexAttribute::new("VertexHeight", 8, VertexFormat::Float32);
|
||||||
|
|
||||||
pub const ATTRIBUTE_TEXTURE_INDEX: MeshVertexAttribute =
|
pub const ATTRIBUTE_TEXTURE_INDEX: MeshVertexAttribute =
|
||||||
MeshVertexAttribute::new("TextureIndex", 988540917, VertexFormat::Uint32);
|
MeshVertexAttribute::new("TextureIndex", 988540917, VertexFormat::Uint32);
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ pub fn generate_chunk_mesh(chunk: &MeshChunkData) -> Mesh {
|
|||||||
// &mut tex,
|
// &mut tex,
|
||||||
chunk.textures[idx][0],
|
chunk.textures[idx][0],
|
||||||
chunk.textures[idx][1],
|
chunk.textures[idx][1],
|
||||||
chunk.overlay_textures[idx],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,14 +63,10 @@ fn create_tile(
|
|||||||
normals: &mut Vec<Vec3>,
|
normals: &mut Vec<Vec3>,
|
||||||
texture_index: u32,
|
texture_index: u32,
|
||||||
side_texture_index: u32,
|
side_texture_index: u32,
|
||||||
side_overlay_texture_index: Option<u32>,
|
|
||||||
) {
|
) {
|
||||||
let uv_offset = Vec2::splat(0.5);
|
let uv_offset = Vec2::splat(0.5);
|
||||||
let tex_off = Vec2::new(texture_index as f32, 0.);
|
let tex_off = Vec2::new(texture_index as f32, 0.);
|
||||||
let side_tex_off = Vec2::new(
|
let side_tex_off = Vec2::new(side_texture_index as f32, 0.);
|
||||||
pack_texture_data(side_texture_index, side_overlay_texture_index) as f32,
|
|
||||||
0.,
|
|
||||||
);
|
|
||||||
|
|
||||||
let idx = verts.len() as u32;
|
let idx = verts.len() as u32;
|
||||||
for i in 0..6 {
|
for i in 0..6 {
|
||||||
@@ -283,13 +278,6 @@ fn create_tile_wall(
|
|||||||
uvs.push((Vec2::new(1., pos.y - height) / TEX_MULTI) + tex_off);
|
uvs.push((Vec2::new(1., pos.y - height) / TEX_MULTI) + tex_off);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pack_texture_data(texture: u32, overlay: Option<u32>) -> u32 {
|
|
||||||
if let Some(ovr) = overlay {
|
|
||||||
return texture + (ovr << 5);
|
|
||||||
}
|
|
||||||
return texture + (texture << 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
@@ -332,17 +320,7 @@ mod tests {
|
|||||||
//4 side faces
|
//4 side faces
|
||||||
let nbors = [2.0, 2.0, 0.0, 0.0, 0.0, 0.0];
|
let nbors = [2.0, 2.0, 0.0, 0.0, 0.0, 0.0];
|
||||||
|
|
||||||
create_tile(
|
create_tile(Vec3::Y, &nbors, &mut verts, &mut uvs, &mut indices, &mut normals, 3, 7);
|
||||||
Vec3::Y,
|
|
||||||
&nbors,
|
|
||||||
&mut verts,
|
|
||||||
&mut uvs,
|
|
||||||
&mut indices,
|
|
||||||
&mut normals,
|
|
||||||
3,
|
|
||||||
7,
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
|
|
||||||
assert!(verts.len() == (6 + 4 * 4), "Number of verts don't match");
|
assert!(verts.len() == (6 + 4 * 4), "Number of verts don't match");
|
||||||
assert!(uvs.len() == (6 + 4 * 4), "Number of uvs don't match");
|
assert!(uvs.len() == (6 + 4 * 4), "Number of uvs don't match");
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
use crate::hex_utils::HexCoord;
|
use crate::hex_utils::{offset3d_to_world, HexCoord};
|
||||||
use crate::map::biome_map::BiomeChunk;
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::tile_manager::TileAsset;
|
|
||||||
use crate::tile_mapper::TileMapperAsset;
|
|
||||||
use crate::{biome_asset::BiomeAsset, biome_painter::BiomePainterAsset};
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
render::{
|
render::{
|
||||||
@@ -12,15 +8,7 @@ use bevy::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn generate_packed_chunk_mesh(
|
pub fn generate_packed_chunk_mesh(chunk: &MeshChunkData) -> Mesh {
|
||||||
chunk: &Chunk,
|
|
||||||
map: &Map,
|
|
||||||
biome_chunk: &BiomeChunk,
|
|
||||||
painter: &BiomePainterAsset,
|
|
||||||
tiles: &Res<Assets<TileAsset>>,
|
|
||||||
biomes: &Res<Assets<BiomeAsset>>,
|
|
||||||
mappers: &Res<Assets<TileMapperAsset>>,
|
|
||||||
) -> Mesh {
|
|
||||||
let vertex_count: usize = Chunk::SIZE * Chunk::SIZE * 6;
|
let vertex_count: usize = Chunk::SIZE * Chunk::SIZE * 6;
|
||||||
let mut packed_data = Vec::with_capacity(vertex_count);
|
let mut packed_data = Vec::with_capacity(vertex_count);
|
||||||
let mut indices = Vec::with_capacity(vertex_count);
|
let mut indices = Vec::with_capacity(vertex_count);
|
||||||
@@ -28,16 +16,10 @@ pub fn generate_packed_chunk_mesh(
|
|||||||
|
|
||||||
for z in 0..Chunk::SIZE {
|
for z in 0..Chunk::SIZE {
|
||||||
for x in 0..Chunk::SIZE {
|
for x in 0..Chunk::SIZE {
|
||||||
let height = chunk.heights[x + z * Chunk::SIZE];
|
let idx = x + z * Chunk::SIZE;
|
||||||
let data = biome_chunk.data[x + z * Chunk::SIZE];
|
let height = chunk.heights[idx];
|
||||||
let coord =
|
let coord = HexCoord::from_grid_pos(x, z);
|
||||||
HexCoord::from_offset(IVec2::new(x as i32, z as i32) + (chunk.chunk_offset * Chunk::SIZE as i32));
|
let n = chunk.get_neighbors(&coord);
|
||||||
let n = map.get_neighbors(&coord);
|
|
||||||
let biome = biomes.get(painter.sample_biome(biomes, &data)).unwrap();
|
|
||||||
|
|
||||||
let mapper = mappers.get(biome.tile_mapper.id());
|
|
||||||
let tile_handle = mapper.unwrap().sample_tile(height);
|
|
||||||
let tile = tiles.get(tile_handle).unwrap();
|
|
||||||
|
|
||||||
create_packed_tile(
|
create_packed_tile(
|
||||||
UVec2::new(x as u32, z as u32),
|
UVec2::new(x as u32, z as u32),
|
||||||
@@ -46,8 +28,8 @@ pub fn generate_packed_chunk_mesh(
|
|||||||
&mut packed_data,
|
&mut packed_data,
|
||||||
&mut indices,
|
&mut indices,
|
||||||
&mut heights,
|
&mut heights,
|
||||||
tile.texture_id,
|
chunk.textures[idx][0],
|
||||||
tile.side_texture_id,
|
chunk.textures[idx][1],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,7 +47,7 @@ pub fn generate_packed_chunk_mesh(
|
|||||||
fn create_packed_tile(
|
fn create_packed_tile(
|
||||||
offset: UVec2,
|
offset: UVec2,
|
||||||
height: f32,
|
height: f32,
|
||||||
neighbors: &[Option<f32>; 6],
|
neighbors: &[f32; 6],
|
||||||
packed_data: &mut Vec<u32>,
|
packed_data: &mut Vec<u32>,
|
||||||
indices: &mut Vec<u32>,
|
indices: &mut Vec<u32>,
|
||||||
heights: &mut Vec<f32>,
|
heights: &mut Vec<f32>,
|
||||||
@@ -85,23 +67,18 @@ fn create_packed_tile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i in 0..neighbors.len() {
|
for i in 0..neighbors.len() {
|
||||||
let cur_n = neighbors[i];
|
let n_height = neighbors[i];
|
||||||
match cur_n {
|
if n_height < height {
|
||||||
Some(n_height) => {
|
create_packed_tile_wall(
|
||||||
if n_height < height {
|
offset,
|
||||||
create_packed_tile_wall(
|
height,
|
||||||
offset,
|
n_height,
|
||||||
height,
|
i,
|
||||||
n_height,
|
packed_data,
|
||||||
i,
|
indices,
|
||||||
packed_data,
|
heights,
|
||||||
indices,
|
side_texture_index,
|
||||||
heights,
|
);
|
||||||
side_texture_index,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
use crate::hex_utils::SHORT_DIAGONAL;
|
use crate::hex_utils::SHORT_DIAGONAL;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Chunk {
|
pub struct Chunk {
|
||||||
pub heights: [f32; Chunk::AREA],
|
pub heights: [f32; Chunk::AREA],
|
||||||
pub textures: [[u32; 2]; Chunk::AREA],
|
pub textures: [[u32; 2]; Chunk::AREA],
|
||||||
pub overlay_textures: [Option<u32>; Chunk::AREA],
|
|
||||||
// pub biome_data: [BiomeData; Chunk::AREA],
|
// pub biome_data: [BiomeData; Chunk::AREA],
|
||||||
pub biome_id: [usize; Chunk::AREA],
|
pub biome_id: [usize; Chunk::AREA],
|
||||||
pub chunk_offset: IVec2,
|
pub chunk_offset: IVec2,
|
||||||
@@ -18,7 +18,6 @@ impl Default for Chunk {
|
|||||||
Self {
|
Self {
|
||||||
heights: [0.; Chunk::AREA],
|
heights: [0.; Chunk::AREA],
|
||||||
textures: [[0; 2]; Chunk::AREA],
|
textures: [[0; 2]; Chunk::AREA],
|
||||||
overlay_textures: [None; Chunk::AREA],
|
|
||||||
// biome_data: [BiomeData::default(); Chunk::AREA],
|
// biome_data: [BiomeData::default(); Chunk::AREA],
|
||||||
biome_id: [0; Chunk::AREA],
|
biome_id: [0; Chunk::AREA],
|
||||||
chunk_offset: Default::default(),
|
chunk_offset: Default::default(),
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ use bevy::prelude::*;
|
|||||||
|
|
||||||
use crate::hex_utils::*;
|
use crate::hex_utils::*;
|
||||||
|
|
||||||
use super::{chunk::Chunk, mesh_chunk::MeshChunkData};
|
use super::{
|
||||||
|
chunk::Chunk,
|
||||||
|
mesh_chunk::MeshChunkData,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Resource, Clone)]
|
#[derive(Resource, Clone)]
|
||||||
pub struct Map {
|
pub struct Map {
|
||||||
@@ -38,7 +41,6 @@ impl Map {
|
|||||||
sealevel: self.sealevel,
|
sealevel: self.sealevel,
|
||||||
heights: chunk.heights.clone(),
|
heights: chunk.heights.clone(),
|
||||||
textures: chunk.textures.clone(),
|
textures: chunk.textures.clone(),
|
||||||
overlay_textures: chunk.overlay_textures.clone(),
|
|
||||||
distance_to_land: self.get_distance_from_land(chunk.chunk_offset, 4),
|
distance_to_land: self.get_distance_from_land(chunk.chunk_offset, 4),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
use std::ops::Add;
|
use std::ops::Add;
|
||||||
|
|
||||||
use bevy::{math::VectorSpace, prelude::*};
|
use bevy::{asset::AssetLoader, math::VectorSpace, prelude::*};
|
||||||
use image::ImageBuffer;
|
use image::ImageBuffer;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
|
|
||||||
use crate::hex_utils::HexCoord;
|
use crate::hex_utils::HexCoord;
|
||||||
|
|
||||||
use super::{
|
use super::{biome_map::BiomeMap, chunk::Chunk, map::Map};
|
||||||
biome_map::BiomeMap,
|
|
||||||
chunk::Chunk,
|
|
||||||
map::Map,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn render_image(
|
pub fn render_image(
|
||||||
size: UVec2,
|
size: UVec2,
|
||||||
@@ -40,7 +36,7 @@ pub fn update_image(
|
|||||||
let idx = (y * w + x) as usize;
|
let idx = (y * w + x) as usize;
|
||||||
let v = data[idx];
|
let v = data[idx];
|
||||||
let t = v.remap(min, max, 0.0, 1.0);
|
let t = v.remap(min, max, 0.0, 1.0);
|
||||||
let col = LinearRgba::lerp(&color1, color2, t);
|
let col = LinearRgba::lerp(color1, color2, t);
|
||||||
*pixel = to_pixel(&col);
|
*pixel = to_pixel(&col);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -95,10 +91,10 @@ fn get_height_color_blend(base_color: Hsla, height: f32, height2: f32, smooth: f
|
|||||||
d /= smooth;
|
d /= smooth;
|
||||||
if d > 0.0 {
|
if d > 0.0 {
|
||||||
let c2: LinearRgba = color.with_lightness(color.lightness + 0.1).into();
|
let c2: LinearRgba = color.with_lightness(color.lightness + 0.1).into();
|
||||||
color = LinearRgba::lerp(&color.into(), c2, d).into();
|
color = LinearRgba::lerp(color.into(), c2, d).into();
|
||||||
} else {
|
} else {
|
||||||
let c2: LinearRgba = color.with_lightness(color.lightness - 0.1).into();
|
let c2: LinearRgba = color.with_lightness(color.lightness - 0.1).into();
|
||||||
color = LinearRgba::lerp(&color.into(), c2, d.abs()).into();
|
color = LinearRgba::lerp(color.into(), c2, d.abs()).into();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ use super::chunk::Chunk;
|
|||||||
pub struct MeshChunkData {
|
pub struct MeshChunkData {
|
||||||
pub heights: [f32; Chunk::AREA],
|
pub heights: [f32; Chunk::AREA],
|
||||||
pub textures: [[u32; 2]; Chunk::AREA],
|
pub textures: [[u32; 2]; Chunk::AREA],
|
||||||
pub overlay_textures: [Option<u32>; Chunk::AREA],
|
|
||||||
pub min_height: f32,
|
pub min_height: f32,
|
||||||
pub sealevel: f32,
|
pub sealevel: f32,
|
||||||
pub distance_to_land: [f32; Chunk::AREA],
|
pub distance_to_land: [f32; Chunk::AREA],
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ pub struct TileAsset {
|
|||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub texture: String,
|
pub texture: String,
|
||||||
pub side_texture_id: u32,
|
pub side_texture_id: u32,
|
||||||
pub side_overlay_id: Option<u32>,
|
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub side_texture: String,
|
pub side_texture: String,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.14.2"
|
bevy = "0.15.1"
|
||||||
world_generation = { path = "../../engine/world_generation" }
|
world_generation = { path = "../../engine/world_generation" }
|
||||||
shared = { path = "../shared" }
|
shared = { path = "../shared" }
|
||||||
bevy_rapier3d = "0.27.0"
|
bevy_rapier3d = "0.28.0"
|
||||||
serde = { version = "1.0.204", features = ["derive"] }
|
serde = { version = "1.0.204", features = ["derive"] }
|
||||||
asset_loader = { path = "../../engine/asset_loader" }
|
asset_loader = { path = "../../engine/asset_loader" }
|
||||||
serde_json = "1.0.120"
|
serde_json = "1.0.120"
|
||||||
ron = "0.8.1"
|
ron = "0.8.1"
|
||||||
bevy_asset_loader = { version = "0.21.0", features = [
|
bevy_asset_loader = { version = "0.22.0", features = [
|
||||||
"standard_dynamic_assets",
|
"standard_dynamic_assets",
|
||||||
"3d",
|
"3d",
|
||||||
] }
|
] }
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
use asset_loader::create_asset_loader;
|
use asset_loader::create_asset_loader;
|
||||||
use bevy::prelude::*;
|
use bevy::{
|
||||||
|
gltf::{GltfMesh, GltfNode},
|
||||||
|
prelude::*,
|
||||||
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use shared::identifiers::ResourceIdentifier;
|
use shared::{component_defination::ComponentDefination, identifiers::ResourceIdentifier, prefab_defination::*};
|
||||||
|
|
||||||
use crate::footprint::BuildingFootprint;
|
use crate::{
|
||||||
|
buildings::{
|
||||||
|
conduit_building::ResourceConduitInfo, factory_building::FactoryBuildingInfo,
|
||||||
|
resource_gathering::ResourceGatheringBuildingInfo,
|
||||||
|
},
|
||||||
|
footprint::BuildingFootprint,
|
||||||
|
prelude::Building,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Asset, TypePath, Debug, Serialize, Deserialize)]
|
#[derive(Asset, TypePath, Debug, Serialize, Deserialize)]
|
||||||
pub struct BuildingAsset {
|
pub struct BuildingAsset {
|
||||||
@@ -12,11 +22,108 @@ pub struct BuildingAsset {
|
|||||||
pub footprint: BuildingFootprint,
|
pub footprint: BuildingFootprint,
|
||||||
pub prefab_path: String,
|
pub prefab_path: String,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub prefab: Handle<Scene>,
|
pub prefab: Handle<Gltf>,
|
||||||
|
pub base_mesh_path: String,
|
||||||
|
|
||||||
pub cost: Vec<ResourceIdentifier>,
|
pub cost: Vec<ResourceIdentifier>,
|
||||||
pub consumption: Vec<ResourceIdentifier>,
|
pub consumption: Vec<ResourceIdentifier>,
|
||||||
pub production: Vec<ResourceIdentifier>,
|
pub production: Vec<ResourceIdentifier>,
|
||||||
|
|
||||||
|
pub health: u32,
|
||||||
|
|
||||||
|
pub building_type: BuildingType,
|
||||||
|
pub components: Option<Vec<ComponentDefination>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BuildingAsset {
|
||||||
|
pub fn spawn(
|
||||||
|
&self,
|
||||||
|
pos: Vec3,
|
||||||
|
rot: Quat,
|
||||||
|
gltf: &Gltf,
|
||||||
|
commands: &mut Commands,
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, TypePath)]
|
||||||
|
pub enum BuildingType {
|
||||||
|
Basic,
|
||||||
|
Gathering(ResourceGatheringBuildingInfo),
|
||||||
|
FactoryBuildingInfo(FactoryBuildingInfo),
|
||||||
|
ResourceConduit(ResourceConduitInfo),
|
||||||
}
|
}
|
||||||
|
|
||||||
create_asset_loader!(
|
create_asset_loader!(
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
use std::f32::consts::E;
|
use std::f32::consts::E;
|
||||||
|
|
||||||
use bevy::{ecs::world::CommandQueue, prelude::*, window::PrimaryWindow};
|
use bevy::{
|
||||||
|
ecs::world::CommandQueue,
|
||||||
|
gltf::{GltfMesh, GltfNode},
|
||||||
|
prelude::*,
|
||||||
|
window::PrimaryWindow,
|
||||||
|
};
|
||||||
use bevy_asset_loader::loading_state::{
|
use bevy_asset_loader::loading_state::{
|
||||||
config::{ConfigureLoadingState, LoadingStateConfig},
|
config::{ConfigureLoadingState, LoadingStateConfig},
|
||||||
LoadingStateAppExt,
|
LoadingStateAppExt,
|
||||||
@@ -87,7 +92,6 @@ fn hq_placement(
|
|||||||
mut build_queue: ResMut<BuildQueue>,
|
mut build_queue: ResMut<BuildQueue>,
|
||||||
mut next_state: ResMut<NextState<GameplayState>>,
|
mut next_state: ResMut<NextState<GameplayState>>,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if let Some(contact) = tile_under_cursor.0 {
|
if let Some(contact) = tile_under_cursor.0 {
|
||||||
let positions = map.hex_select(&contact.tile, 3, true, |pos, h, _| pos.to_world(h));
|
let positions = map.hex_select(&contact.tile, 3, true, |pos, h, _| pos.to_world(h));
|
||||||
show_indicators(positions, &mut commands, &indicator);
|
show_indicators(positions, &mut commands, &indicator);
|
||||||
@@ -106,12 +110,9 @@ fn hq_placement(
|
|||||||
fn show_indicators(positions: Vec<Vec3>, commands: &mut Commands, indicator: &IndicatorCube) {
|
fn show_indicators(positions: Vec<Vec3>, commands: &mut Commands, indicator: &IndicatorCube) {
|
||||||
for p in positions {
|
for p in positions {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
PbrBundle {
|
Mesh3d(indicator.0.clone()),
|
||||||
mesh: indicator.0.clone(),
|
MeshMaterial3d(indicator.1.clone()),
|
||||||
material: indicator.1.clone(),
|
Transform::from_translation(p),
|
||||||
transform: Transform::from_translation(p),
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
Despawn,
|
Despawn,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -122,6 +123,9 @@ fn process_build_queue(
|
|||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
db: Res<BuildingDatabase>,
|
db: Res<BuildingDatabase>,
|
||||||
building_assets: Res<Assets<BuildingAsset>>,
|
building_assets: Res<Assets<BuildingAsset>>,
|
||||||
|
gltf_assets: Res<Assets<Gltf>>,
|
||||||
|
gltf_meshes: Res<Assets<GltfMesh>>,
|
||||||
|
gltf_nodes: Res<Assets<GltfNode>>,
|
||||||
mut building_map: ResMut<BuildingMap>,
|
mut building_map: ResMut<BuildingMap>,
|
||||||
heightmap: Res<Map>,
|
heightmap: Res<Map>,
|
||||||
) {
|
) {
|
||||||
@@ -130,16 +134,21 @@ fn process_build_queue(
|
|||||||
if let Some(building) = building_assets.get(handle.id()) {
|
if let Some(building) = building_assets.get(handle.id()) {
|
||||||
let h = heightmap.sample_height(&item.pos);
|
let h = heightmap.sample_height(&item.pos);
|
||||||
println!("Spawning {} at {}", building.name, item.pos);
|
println!("Spawning {} at {}", building.name, item.pos);
|
||||||
let e = commands.spawn((
|
if let Some(gltf) = gltf_assets.get(building.prefab.id()) {
|
||||||
SceneBundle {
|
let e = building.spawn(
|
||||||
scene: building.prefab.clone(),
|
item.pos.to_world(h),
|
||||||
transform: Transform::from_translation(item.pos.to_world(h)),
|
Quat::IDENTITY,
|
||||||
..Default::default()
|
gltf,
|
||||||
},
|
&mut commands,
|
||||||
Building,
|
&gltf_meshes,
|
||||||
));
|
&gltf_nodes,
|
||||||
|
);
|
||||||
building_map.add_building(BuildingEntry::new(item.pos, e.id()));
|
if let Some(b) = e {
|
||||||
|
building_map.add_building(BuildingEntry::new(item.pos, b));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
warn!("Failed to spawn building");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queue.queue.clear();
|
queue.queue.clear();
|
||||||
|
|||||||
3
game/buildings/src/buildings/basic_building.rs
Normal file
3
game/buildings/src/buildings/basic_building.rs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct BasicBuildingInfo {}
|
||||||
6
game/buildings/src/buildings/conduit_building.rs
Normal file
6
game/buildings/src/buildings/conduit_building.rs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct ResourceConduitInfo {
|
||||||
|
pub range: usize,
|
||||||
|
pub connection_range: usize,
|
||||||
|
}
|
||||||
6
game/buildings/src/buildings/factory_building.rs
Normal file
6
game/buildings/src/buildings/factory_building.rs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct FactoryBuildingInfo {
|
||||||
|
pub units_to_build: Vec<()>
|
||||||
|
}
|
||||||
5
game/buildings/src/buildings/mod.rs
Normal file
5
game/buildings/src/buildings/mod.rs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
pub mod basic_building;
|
||||||
|
pub mod conduit_building;
|
||||||
|
pub mod factory_building;
|
||||||
|
pub mod resource_gathering;
|
||||||
|
pub mod tech_building;
|
||||||
8
game/buildings/src/buildings/resource_gathering.rs
Normal file
8
game/buildings/src/buildings/resource_gathering.rs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use shared::identifiers::ResourceIdentifier;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct ResourceGatheringBuildingInfo {
|
||||||
|
pub resources_to_gather: Vec<ResourceIdentifier>,
|
||||||
|
pub gather_range: usize,
|
||||||
|
}
|
||||||
9
game/buildings/src/buildings/tech_building.rs
Normal file
9
game/buildings/src/buildings/tech_building.rs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use shared::{building::BuildingIdentifier, StatusEffect};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct TechBuildingInfo {
|
||||||
|
pub effect_range: usize,
|
||||||
|
pub buildings_to_unlock: Vec<BuildingIdentifier>,
|
||||||
|
pub buffs: Vec<StatusEffect>,
|
||||||
|
}
|
||||||
@@ -4,4 +4,5 @@ pub mod building_plugin;
|
|||||||
pub mod buildings_map;
|
pub mod buildings_map;
|
||||||
pub mod footprint;
|
pub mod footprint;
|
||||||
pub mod prelude;
|
pub mod prelude;
|
||||||
|
mod buildings;
|
||||||
pub use building_plugin::*;
|
pub use building_plugin::*;
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ 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.14.2", features = ["file_watcher"] }
|
bevy = { version = "0.15.1", features = ["file_watcher"] }
|
||||||
bevy-inspector-egui = "0.25.0"
|
bevy-inspector-egui = "0.28.1"
|
||||||
iyes_perf_ui = "0.3.0"
|
# iyes_perf_ui = "0.3.0"
|
||||||
noise = "0.8.2"
|
noise = "0.8.2"
|
||||||
world_generation = { path = "../../engine/world_generation" }
|
world_generation = { path = "../../engine/world_generation" }
|
||||||
bevy_rapier3d = { version = "0.27.0", features = [
|
bevy_rapier3d = { version = "0.28.0", features = [
|
||||||
"simd-stable",
|
"simd-stable",
|
||||||
"parallel",
|
"parallel",
|
||||||
"debug-render-3d",
|
"debug-render-3d",
|
||||||
@@ -21,12 +21,13 @@ rayon = "1.10.0"
|
|||||||
buildings = { path = "../buildings" }
|
buildings = { path = "../buildings" }
|
||||||
units = { path = "../units" }
|
units = { path = "../units" }
|
||||||
shared = { path = "../shared" }
|
shared = { path = "../shared" }
|
||||||
bevy_asset_loader = { version = "0.21.0", features = [
|
bevy_asset_loader = { version = "0.22.0", features = [
|
||||||
"standard_dynamic_assets",
|
"standard_dynamic_assets",
|
||||||
"3d",
|
"3d",
|
||||||
] }
|
] }
|
||||||
ron = "0.8.1"
|
ron = "0.8.1"
|
||||||
image = "0.25.2"
|
image = "0.25.2"
|
||||||
|
# bevy_lunex = "0.2.4"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
tracing = [
|
tracing = [
|
||||||
|
|||||||
Submodule game/main/assets updated: 67cf2d46ce...f1c26c1519
@@ -13,6 +13,10 @@ where
|
|||||||
|
|
||||||
for path in fs::read_dir(from).unwrap() {
|
for path in fs::read_dir(from).unwrap() {
|
||||||
let path = path.unwrap().path();
|
let path = path.unwrap().path();
|
||||||
|
println!("{path:?}");
|
||||||
|
if path.starts_with("assets/raw_assets") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let to = to.clone().join(path.file_name().unwrap());
|
let to = to.clone().join(path.file_name().unwrap());
|
||||||
|
|
||||||
if path.is_file() {
|
if path.is_file() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use bevy::core_pipeline::experimental::taa::{TemporalAntiAliasBundle, TemporalAntiAliasPlugin};
|
use bevy::core_pipeline::experimental::taa::{TemporalAntiAliasBundle, 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::*;
|
||||||
@@ -20,13 +20,9 @@ impl Plugin for PhosCameraPlugin {
|
|||||||
|
|
||||||
app.add_systems(PreStartup, setup);
|
app.add_systems(PreStartup, setup);
|
||||||
|
|
||||||
// app.add_systems(Update, rts_camera_system.in_set(GameplaySet));
|
|
||||||
// app.add_systems(PostUpdate, limit_camera_bounds.in_set(GameplaySet));
|
|
||||||
app.add_systems(Update, orbit_camera_upate.in_set(GameplaySet));
|
app.add_systems(Update, orbit_camera_upate.in_set(GameplaySet));
|
||||||
|
|
||||||
app.add_systems(Update, init_bounds.run_if(in_state(GeneratorState::SpawnMap)));
|
app.add_systems(Update, init_bounds.run_if(in_state(GeneratorState::SpawnMap)));
|
||||||
//Free Cam
|
|
||||||
//app.add_systems(Update, (grab_mouse, (update_camera, update_camera_mouse).chain()));
|
|
||||||
|
|
||||||
app.add_plugins(TemporalAntiAliasPlugin);
|
app.add_plugins(TemporalAntiAliasPlugin);
|
||||||
}
|
}
|
||||||
@@ -48,21 +44,21 @@ fn init_bounds(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, mut msaa: ResMut<Msaa>) {
|
fn setup(mut commands: Commands) {
|
||||||
commands
|
commands
|
||||||
.spawn((
|
.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
transform: Transform::from_xyz(0., 30., 0.).looking_to(Vec3::NEG_Z, Vec3::Y),
|
Transform::from_xyz(0., 30., 0.).looking_to(Vec3::NEG_Z, Vec3::Y),
|
||||||
..default()
|
|
||||||
},
|
|
||||||
PhosCamera::default(),
|
PhosCamera::default(),
|
||||||
MainCamera,
|
MainCamera,
|
||||||
DepthPrepass,
|
DepthPrepass,
|
||||||
PhosOrbitCamera::default(),
|
PhosOrbitCamera::default(),
|
||||||
|
TemporalAntiAliasing::default(),
|
||||||
))
|
))
|
||||||
.insert(TemporalAntiAliasBundle::default());
|
.insert(Msaa::Off);
|
||||||
|
// .insert(RenderLayers::layer(0))
|
||||||
|
|
||||||
*msaa = Msaa::Off;
|
// *msaa = Msaa::Off;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn orbit_camera_upate(
|
fn orbit_camera_upate(
|
||||||
@@ -90,24 +86,24 @@ fn orbit_camera_upate(
|
|||||||
for e in mouse_motion.read() {
|
for e in mouse_motion.read() {
|
||||||
orbit_move += e.delta;
|
orbit_move += e.delta;
|
||||||
}
|
}
|
||||||
orbit_move *= config.pan_speed * time.delta_seconds() * -1.0;
|
orbit_move *= config.pan_speed * time.delta_secs() * -1.0;
|
||||||
let rot_y = Quat::from_axis_angle(Vec3::Y, orbit_move.x);
|
let rot_y = Quat::from_axis_angle(Vec3::Y, orbit_move.x);
|
||||||
let right = orbit.forward.cross(Vec3::Y).normalize();
|
let right = orbit.forward.cross(Vec3::Y).normalize();
|
||||||
let rot_x = Quat::from_axis_angle(right, orbit_move.y);
|
let rot_x = Quat::from_axis_angle(right, orbit_move.y);
|
||||||
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.grab_mode = CursorGrabMode::Locked;
|
window.cursor_options.grab_mode = CursorGrabMode::Locked;
|
||||||
window.cursor.visible = false;
|
window.cursor_options.visible = false;
|
||||||
} else {
|
} else {
|
||||||
window.cursor.grab_mode = CursorGrabMode::None;
|
window.cursor_options.grab_mode = CursorGrabMode::None;
|
||||||
window.cursor.visible = true;
|
window.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_seconds());
|
let rot = Quat::from_axis_angle(Vec3::Y, f32::to_radians(config.speed) * time.delta_secs());
|
||||||
orbit.forward = rot * orbit.forward;
|
orbit.forward = rot * orbit.forward;
|
||||||
} else if key.pressed(KeyCode::KeyQ) {
|
} else if key.pressed(KeyCode::KeyQ) {
|
||||||
let rot = Quat::from_axis_angle(Vec3::Y, f32::to_radians(-config.speed) * time.delta_seconds());
|
let rot = Quat::from_axis_angle(Vec3::Y, f32::to_radians(-config.speed) * time.delta_secs());
|
||||||
orbit.forward = rot * orbit.forward;
|
orbit.forward = rot * orbit.forward;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +136,7 @@ fn orbit_camera_upate(
|
|||||||
gizmos.arrow(orbit.target, orbit.target + move_fwd, LinearRgba::WHITE.with_alpha(0.5));
|
gizmos.arrow(orbit.target, orbit.target + move_fwd, LinearRgba::WHITE.with_alpha(0.5));
|
||||||
gizmos.arrow(orbit.target, orbit.target - (move_rot * cam_move), LinearRgba::BLUE);
|
gizmos.arrow(orbit.target, orbit.target - (move_rot * cam_move), LinearRgba::BLUE);
|
||||||
}
|
}
|
||||||
orbit.target -= (move_rot * cam_move) * move_speed * time.delta_seconds();
|
orbit.target -= (move_rot * cam_move) * move_speed * time.delta_secs();
|
||||||
orbit.target.y = sample_ground(orbit.target, &map);
|
orbit.target.y = sample_ground(orbit.target, &map);
|
||||||
|
|
||||||
orbit.target.x = orbit.target.x.clamp(bounds.min.x, bounds.max.x);
|
orbit.target.x = orbit.target.x.clamp(bounds.min.x, bounds.max.x);
|
||||||
@@ -155,7 +151,7 @@ fn orbit_camera_upate(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
orbit.distance -= scroll * time.delta_seconds() * config.zoom_speed;
|
orbit.distance -= scroll * time.delta_secs() * config.zoom_speed;
|
||||||
orbit.distance = orbit.distance.clamp(config.min_height, config.max_height);
|
orbit.distance = orbit.distance.clamp(config.min_height, config.max_height);
|
||||||
|
|
||||||
// let ground_below_cam = sample_ground(cam_pos, &map) + config.min_height;
|
// let ground_below_cam = sample_ground(cam_pos, &map) + config.min_height;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ impl Default for PhosCamera {
|
|||||||
max_height: 420.,
|
max_height: 420.,
|
||||||
speed: 100.,
|
speed: 100.,
|
||||||
pan_speed: Vec2::new(0.8, 0.5),
|
pan_speed: Vec2::new(0.8, 0.5),
|
||||||
zoom_speed: 200.,
|
zoom_speed: 20.,
|
||||||
min_angle: (20. as f32).to_radians(),
|
min_angle: (20. as f32).to_radians(),
|
||||||
max_angle: 1.,
|
max_angle: 1.,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
use std::env;
|
||||||
|
|
||||||
|
use bevy::image::{ImageAddressMode, ImageFilterMode, ImageSamplerDescriptor};
|
||||||
use bevy::pbr::wireframe::WireframePlugin;
|
use bevy::pbr::wireframe::WireframePlugin;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::render::texture::{ImageAddressMode, ImageFilterMode, ImageSamplerDescriptor};
|
|
||||||
use bevy::window::PresentMode;
|
use bevy::window::PresentMode;
|
||||||
use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
||||||
use phos::PhosGamePlugin;
|
use phos::PhosGamePlugin;
|
||||||
@@ -10,8 +12,8 @@ mod map_rendering;
|
|||||||
mod phos;
|
mod phos;
|
||||||
mod prelude;
|
mod prelude;
|
||||||
mod shader_extensions;
|
mod shader_extensions;
|
||||||
mod utlis;
|
|
||||||
mod ui;
|
mod ui;
|
||||||
|
mod utlis;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
|
|||||||
@@ -73,14 +73,14 @@ fn chunk_rebuilder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn collider_task_resolver(
|
fn collider_task_resolver(
|
||||||
mut chunks: Query<(&mut ChunkRebuildTask, &Handle<Mesh>), With<PhosChunk>>,
|
mut chunks: Query<(&mut ChunkRebuildTask, &Mesh3d), With<PhosChunk>>,
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
) {
|
) {
|
||||||
for (mut task, mesh_handle) in &mut chunks {
|
for (mut task, mesh_handle) in &mut chunks {
|
||||||
if let Some((mut c, mesh)) = futures::check_ready(&mut task.task) {
|
if let Some((mut c, mesh)) = futures::check_ready(&mut task.task) {
|
||||||
commands.append(&mut c);
|
commands.append(&mut c);
|
||||||
meshes.insert(mesh_handle, mesh);
|
meshes.insert(mesh_handle.id(), mesh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use bevy::log::*;
|
|||||||
use bevy::{
|
use bevy::{
|
||||||
pbr::{ExtendedMaterial, NotShadowCaster},
|
pbr::{ExtendedMaterial, NotShadowCaster},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
|
render::render_resource::{ColorTargetState, FragmentState, RenderPipelineDescriptor},
|
||||||
};
|
};
|
||||||
use bevy_asset_loader::prelude::*;
|
use bevy_asset_loader::prelude::*;
|
||||||
|
|
||||||
@@ -219,6 +220,7 @@ fn spawn_map(
|
|||||||
) {
|
) {
|
||||||
paint_map(&mut heightmap, &biome_painter, &tile_assets, &tile_mappers);
|
paint_map(&mut heightmap, &biome_painter, &tile_assets, &tile_mappers);
|
||||||
|
|
||||||
|
//Prepare Mesh Data
|
||||||
let map_size = UVec2::new(heightmap.width as u32, heightmap.height as u32);
|
let map_size = UVec2::new(heightmap.width as u32, heightmap.height as u32);
|
||||||
let chunk_meshes: Vec<_> = heightmap
|
let chunk_meshes: Vec<_> = heightmap
|
||||||
.chunks
|
.chunks
|
||||||
@@ -236,6 +238,8 @@ fn spawn_map(
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mut registry = PhosChunkRegistry::new(chunk_meshes.len());
|
let mut registry = PhosChunkRegistry::new(chunk_meshes.len());
|
||||||
|
|
||||||
|
//Spawn Chunks
|
||||||
{
|
{
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
let _spawn_span = info_span!("Spawn Chunks").entered();
|
let _spawn_span = info_span!("Spawn Chunks").entered();
|
||||||
@@ -248,12 +252,9 @@ fn spawn_map(
|
|||||||
// let mesh_handle = meshes.a
|
// let mesh_handle = meshes.a
|
||||||
let chunk = commands
|
let chunk = commands
|
||||||
.spawn((
|
.spawn((
|
||||||
MaterialMeshBundle {
|
Mesh3d(meshes.add(chunk_mesh)),
|
||||||
mesh: meshes.add(chunk_mesh),
|
MeshMaterial3d(atlas.chunk_material_handle.clone()),
|
||||||
material: atlas.chunk_material_handle.clone(),
|
Transform::from_translation(pos),
|
||||||
transform: Transform::from_translation(pos),
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
PhosChunk::new(index),
|
PhosChunk::new(index),
|
||||||
RenderDistanceVisibility::default().with_offset(visibility_offset),
|
RenderDistanceVisibility::default().with_offset(visibility_offset),
|
||||||
collider,
|
collider,
|
||||||
@@ -261,12 +262,9 @@ fn spawn_map(
|
|||||||
.id();
|
.id();
|
||||||
let water = commands
|
let water = commands
|
||||||
.spawn((
|
.spawn((
|
||||||
MaterialMeshBundle {
|
Mesh3d(meshes.add(water_mesh)),
|
||||||
mesh: meshes.add(water_mesh),
|
MeshMaterial3d(atlas.water_material.clone()),
|
||||||
material: atlas.water_material.clone(),
|
Transform::from_translation(pos),
|
||||||
transform: Transform::from_translation(pos),
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
PhosChunk::new(index),
|
PhosChunk::new(index),
|
||||||
NotShadowCaster,
|
NotShadowCaster,
|
||||||
RenderDistanceVisibility::default().with_offset(visibility_offset),
|
RenderDistanceVisibility::default().with_offset(visibility_offset),
|
||||||
@@ -277,20 +275,6 @@ fn spawn_map(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// commands.spawn((
|
|
||||||
// MaterialMeshBundle {
|
|
||||||
// transform: Transform::from_translation(heightmap.get_center()),
|
|
||||||
// mesh: meshes.add(
|
|
||||||
// Plane3d::default()
|
|
||||||
// .mesh()
|
|
||||||
// .size(heightmap.get_world_width(), heightmap.get_world_height()),
|
|
||||||
// ),
|
|
||||||
// material: atlas.water_material.clone(),
|
|
||||||
// ..default()
|
|
||||||
// },
|
|
||||||
// NotShadowCaster,
|
|
||||||
// ));
|
|
||||||
|
|
||||||
commands.insert_resource(registry);
|
commands.insert_resource(registry);
|
||||||
generator_state.set(GeneratorState::Idle);
|
generator_state.set(GeneratorState::Idle);
|
||||||
if cur_game_state.get() != &MenuState::InGame {
|
if cur_game_state.get() != &MenuState::InGame {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
use shared::tags::MainCamera;
|
||||||
|
|
||||||
use crate::camera_system::components::PhosCamera;
|
use crate::camera_system::components::PhosCamera;
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ 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<PhosCamera>>,
|
camera_query: Query<&Transform, With<MainCamera>>,
|
||||||
settings: Res<RenderDistanceSettings>,
|
settings: Res<RenderDistanceSettings>,
|
||||||
) {
|
) {
|
||||||
let camera = camera_query.single();
|
let camera = camera_query.single();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use crate::camera_system::components::PhosCamera;
|
use crate::camera_system::components::PhosCamera;
|
||||||
use crate::map_rendering::map_init::MapInitPlugin;
|
use crate::map_rendering::map_init::MapInitPlugin;
|
||||||
use crate::map_rendering::render_distance_system::RenderDistancePlugin;
|
use crate::map_rendering::render_distance_system::RenderDistancePlugin;
|
||||||
|
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};
|
||||||
@@ -13,7 +14,8 @@ 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::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};
|
||||||
@@ -37,6 +39,8 @@ impl Plugin for PhosGamePlugin {
|
|||||||
MapInitPlugin,
|
MapInitPlugin,
|
||||||
RenderDistancePlugin,
|
RenderDistancePlugin,
|
||||||
BuildingPugin,
|
BuildingPugin,
|
||||||
|
BuildUIPlugin,
|
||||||
|
SimpleAnimationPlugin,
|
||||||
UnitsPlugin,
|
UnitsPlugin,
|
||||||
DespawnPuglin,
|
DespawnPuglin,
|
||||||
TileSelectionPlugin,
|
TileSelectionPlugin,
|
||||||
@@ -57,8 +61,8 @@ impl Plugin for PhosGamePlugin {
|
|||||||
//Perf UI
|
//Perf UI
|
||||||
app.add_plugins(bevy::diagnostic::FrameTimeDiagnosticsPlugin)
|
app.add_plugins(bevy::diagnostic::FrameTimeDiagnosticsPlugin)
|
||||||
.add_plugins(bevy::diagnostic::EntityCountDiagnosticsPlugin)
|
.add_plugins(bevy::diagnostic::EntityCountDiagnosticsPlugin)
|
||||||
.add_plugins(bevy::diagnostic::SystemInformationDiagnosticsPlugin)
|
.add_plugins(bevy::diagnostic::SystemInformationDiagnosticsPlugin);
|
||||||
.add_plugins(PerfUiPlugin);
|
// .add_plugins(PerfUiPlugin);
|
||||||
|
|
||||||
//Physics
|
//Physics
|
||||||
app.add_plugins(RapierPhysicsPlugin::<NoUserData>::default());
|
app.add_plugins(RapierPhysicsPlugin::<NoUserData>::default());
|
||||||
@@ -74,52 +78,51 @@ impl Plugin for PhosGamePlugin {
|
|||||||
fn configure_gameplay_set(app: &mut App) {
|
fn configure_gameplay_set(app: &mut App) {
|
||||||
app.configure_sets(
|
app.configure_sets(
|
||||||
Update,
|
Update,
|
||||||
GameplaySet.run_if(in_state(GeneratorState::Idle).and_then(in_state(MenuState::InGame))),
|
GameplaySet.run_if(in_state(GeneratorState::Idle).and(in_state(MenuState::InGame))),
|
||||||
);
|
);
|
||||||
app.configure_sets(
|
app.configure_sets(
|
||||||
PreUpdate,
|
PreUpdate,
|
||||||
GameplaySet.run_if(in_state(GeneratorState::Idle).and_then(in_state(MenuState::InGame))),
|
GameplaySet.run_if(in_state(GeneratorState::Idle).and(in_state(MenuState::InGame))),
|
||||||
);
|
);
|
||||||
app.configure_sets(
|
app.configure_sets(
|
||||||
PostUpdate,
|
PostUpdate,
|
||||||
GameplaySet.run_if(in_state(GeneratorState::Idle).and_then(in_state(MenuState::InGame))),
|
GameplaySet.run_if(in_state(GeneratorState::Idle).and(in_state(MenuState::InGame))),
|
||||||
);
|
);
|
||||||
|
|
||||||
app.configure_sets(
|
app.configure_sets(
|
||||||
FixedUpdate,
|
FixedUpdate,
|
||||||
GameplaySet.run_if(in_state(GeneratorState::Idle).and_then(in_state(MenuState::InGame))),
|
GameplaySet.run_if(in_state(GeneratorState::Idle).and(in_state(MenuState::InGame))),
|
||||||
);
|
);
|
||||||
app.configure_sets(
|
app.configure_sets(
|
||||||
FixedPreUpdate,
|
FixedPreUpdate,
|
||||||
GameplaySet.run_if(in_state(GeneratorState::Idle).and_then(in_state(MenuState::InGame))),
|
GameplaySet.run_if(in_state(GeneratorState::Idle).and(in_state(MenuState::InGame))),
|
||||||
);
|
);
|
||||||
app.configure_sets(
|
app.configure_sets(
|
||||||
FixedPostUpdate,
|
FixedPostUpdate,
|
||||||
GameplaySet.run_if(in_state(GeneratorState::Idle).and_then(in_state(MenuState::InGame))),
|
GameplaySet.run_if(in_state(GeneratorState::Idle).and(in_state(MenuState::InGame))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init_game(mut commands: Commands, mut materials: ResMut<Assets<StandardMaterial>>) {
|
fn init_game(mut commands: Commands, mut materials: ResMut<Assets<StandardMaterial>>) {
|
||||||
commands.spawn((
|
// commands.spawn((
|
||||||
PerfUiRoot::default(),
|
// PerfUiRoot::default(),
|
||||||
PerfUiEntryFPS::default(),
|
// PerfUiEntryFPS::default(),
|
||||||
PerfUiEntryFPSWorst::default(),
|
// PerfUiEntryFPSWorst::default(),
|
||||||
PerfUiEntryFrameTime::default(),
|
// PerfUiEntryFrameTime::default(),
|
||||||
PerfUiEntryFrameTimeWorst::default(),
|
// PerfUiEntryFrameTimeWorst::default(),
|
||||||
));
|
// ));
|
||||||
|
|
||||||
commands.spawn(DirectionalLightBundle {
|
commands.spawn((
|
||||||
directional_light: DirectionalLight {
|
DirectionalLight {
|
||||||
shadows_enabled: true,
|
shadows_enabled: true,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
cascade_shadow_config: CascadeShadowConfig {
|
CascadeShadowConfig {
|
||||||
bounds: vec![200., 400., 600., 800.],
|
bounds: vec![200., 400., 600., 800.],
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
transform: Transform::from_xyz(500., 260.0, 500.).looking_at(Vec3::ZERO, Vec3::Y),
|
Transform::from_xyz(500., 260.0, 500.).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
..default()
|
));
|
||||||
});
|
|
||||||
|
|
||||||
let sphere_mat = StandardMaterial {
|
let sphere_mat = StandardMaterial {
|
||||||
base_color: Color::srgb(1., 1., 0.),
|
base_color: Color::srgb(1., 1., 0.),
|
||||||
@@ -142,12 +145,9 @@ fn spawn_sphere(
|
|||||||
if keyboard_input.just_pressed(KeyCode::KeyF) {
|
if keyboard_input.just_pressed(KeyCode::KeyF) {
|
||||||
let cam_transform = cam.single();
|
let cam_transform = cam.single();
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
MaterialMeshBundle {
|
Mesh3d(meshes.add(Sphere::new(0.3))),
|
||||||
mesh: meshes.add(Sphere::new(0.3)),
|
MeshMaterial3d(mat.0.clone()),
|
||||||
material: mat.0.clone(),
|
Transform::from_translation(cam_transform.translation),
|
||||||
transform: Transform::from_translation(cam_transform.translation),
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
Collider::ball(0.3),
|
Collider::ball(0.3),
|
||||||
RigidBody::Dynamic,
|
RigidBody::Dynamic,
|
||||||
Ccd::enabled(),
|
Ccd::enabled(),
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
use bevy::asset::{Asset, Handle};
|
use bevy::asset::{Asset, Handle};
|
||||||
use bevy::pbr::MaterialExtension;
|
use bevy::image::Image;
|
||||||
|
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, ShaderRef};
|
use bevy::render::render_resource::{AsBindGroup, ShaderRef};
|
||||||
use bevy::render::texture::Image;
|
use world_generation::consts::{ATTRIBUTE_PACKED_VERTEX_DATA, ATTRIBUTE_VERTEX_HEIGHT};
|
||||||
|
|
||||||
#[derive(Asset, TypePath, AsBindGroup, Debug, Clone)]
|
#[derive(Asset, TypePath, AsBindGroup, Debug, Clone)]
|
||||||
pub struct ChunkMaterial {
|
pub struct ChunkMaterial {
|
||||||
@@ -15,25 +17,50 @@ impl MaterialExtension for ChunkMaterial {
|
|||||||
fn fragment_shader() -> ShaderRef {
|
fn fragment_shader() -> ShaderRef {
|
||||||
"shaders/world/chunk.wgsl".into()
|
"shaders/world/chunk.wgsl".into()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// fn vertex_shader() -> ShaderRef {
|
#[derive(Asset, TypePath, AsBindGroup, Debug, Clone)]
|
||||||
|
pub struct PackedChunkMaterial {
|
||||||
|
#[texture(100, dimension = "2d_array")]
|
||||||
|
#[sampler(101)]
|
||||||
|
pub array_texture: Handle<Image>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Material for PackedChunkMaterial {
|
||||||
|
fn fragment_shader() -> ShaderRef {
|
||||||
|
"shaders/world/chunk.wgsl".into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn vertex_shader() -> ShaderRef {
|
||||||
|
"shaders/world/chunk_packed.wgsl".into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn prepass_vertex_shader() -> ShaderRef {
|
||||||
|
"shaders/world/chunk_packed.wgsl".into()
|
||||||
|
}
|
||||||
|
|
||||||
|
// fn deferred_vertex_shader() -> ShaderRef {
|
||||||
// "shaders/world/chunk_packed.wgsl".into()
|
// "shaders/world/chunk_packed.wgsl".into()
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// fn specialize(
|
// fn opaque_render_method(&self) -> bevy::pbr::OpaqueRendererMethod {
|
||||||
// _pipeline: &bevy::pbr::MaterialExtensionPipeline,
|
// return OpaqueRendererMethod::Auto;
|
||||||
// descriptor: &mut bevy::render::render_resource::RenderPipelineDescriptor,
|
|
||||||
// layout: &bevy::render::mesh::MeshVertexBufferLayout,
|
|
||||||
// _key: bevy::pbr::MaterialExtensionKey<Self>,
|
|
||||||
// ) -> Result<(), bevy::render::render_resource::SpecializedMeshPipelineError> {
|
|
||||||
// let vertex_layout = layout.get_layout(&[
|
|
||||||
// // Mesh::ATTRIBUTE_POSITION.at_shader_location(0),
|
|
||||||
// // Mesh::ATTRIBUTE_UV_0.at_shader_location(1),
|
|
||||||
// // Mesh::ATTRIBUTE_NORMAL.at_shader_location(2),
|
|
||||||
// ATTRIBUTE_PACKED_VERTEX_DATA.at_shader_location(7),
|
|
||||||
// ATTRIBUTE_VERTEX_HEIGHT.at_shader_location(8),
|
|
||||||
// ])?;
|
|
||||||
// descriptor.vertex.buffers = vec![vertex_layout];
|
|
||||||
// Ok(())
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
fn specialize(
|
||||||
|
_pipeline: &bevy::pbr::MaterialPipeline<Self>,
|
||||||
|
descriptor: &mut bevy::render::render_resource::RenderPipelineDescriptor,
|
||||||
|
layout: &MeshVertexBufferLayoutRef,
|
||||||
|
_key: bevy::pbr::MaterialPipelineKey<Self>,
|
||||||
|
) -> Result<(), bevy::render::render_resource::SpecializedMeshPipelineError> {
|
||||||
|
let vertex_layout = layout.0.get_layout(&[
|
||||||
|
// Mesh::ATTRIBUTE_POSITION.at_shader_location(0),
|
||||||
|
// Mesh::ATTRIBUTE_UV_0.at_shader_location(1),
|
||||||
|
// Mesh::ATTRIBUTE_NORMAL.at_shader_location(2),
|
||||||
|
ATTRIBUTE_PACKED_VERTEX_DATA.at_shader_location(7),
|
||||||
|
ATTRIBUTE_VERTEX_HEIGHT.at_shader_location(8),
|
||||||
|
])?;
|
||||||
|
descriptor.vertex.buffers = vec![vertex_layout];
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
38
game/main/src/ui/build_ui.rs
Normal file
38
game/main/src/ui/build_ui.rs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
use bevy::{
|
||||||
|
prelude::*,
|
||||||
|
render::{camera::RenderTarget, view::RenderLayers},
|
||||||
|
};
|
||||||
|
use shared::{states::AssetLoadState, tags::MainCamera};
|
||||||
|
pub struct BuildUIPlugin;
|
||||||
|
|
||||||
|
impl Plugin for BuildUIPlugin {
|
||||||
|
fn build(&self, app: &mut App) {
|
||||||
|
app.add_systems(Startup, setup_cameras);
|
||||||
|
app.add_systems(Update, spawn_ui.run_if(in_state(AssetLoadState::LoadComplete)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn setup_cameras(mut commands: Commands) {
|
||||||
|
commands.spawn((Camera2d, IsDefaultUiCamera, UiBoxShadowSamples(6)));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn spawn_ui(mut commands: Commands) {
|
||||||
|
commands
|
||||||
|
.spawn((Node {
|
||||||
|
width: Val::Percent(100.),
|
||||||
|
height: Val::Percent(100.),
|
||||||
|
justify_content: JustifyContent::Center,
|
||||||
|
align_items: AlignItems::End,
|
||||||
|
..default()
|
||||||
|
},))
|
||||||
|
.insert(PickingBehavior::IGNORE)
|
||||||
|
.with_children(|parent| {
|
||||||
|
parent.spawn((
|
||||||
|
Node {
|
||||||
|
width: Val::Px(500.),
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
BackgroundColor(LinearRgba::GREEN.into()),
|
||||||
|
));
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
use bevy::prelude::*;
|
|
||||||
|
|
||||||
pub struct BuildUiPlugin;
|
|
||||||
|
|
||||||
impl Plugin for BuildUiPlugin {
|
|
||||||
fn build(&self, app: &mut App) {
|
|
||||||
app.add_systems(PostStartup, setup);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn setup(mut commands: Commands) {}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
|
|
||||||
pub mod build_ui;
|
|
||||||
@@ -1,2 +1 @@
|
|||||||
|
pub mod build_ui;
|
||||||
pub mod game;
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use world_generation::{
|
|||||||
generators::{
|
generators::{
|
||||||
chunk_colliders::generate_chunk_collider,
|
chunk_colliders::generate_chunk_collider,
|
||||||
mesh_generator::{generate_chunk_mesh, generate_chunk_water_mesh},
|
mesh_generator::{generate_chunk_mesh, generate_chunk_water_mesh},
|
||||||
|
packed_mesh_generator::generate_packed_chunk_mesh,
|
||||||
},
|
},
|
||||||
hex_utils::offset_to_world,
|
hex_utils::offset_to_world,
|
||||||
prelude::{Chunk, Map, MeshChunkData},
|
prelude::{Chunk, Map, MeshChunkData},
|
||||||
@@ -47,7 +48,6 @@ pub fn paint_chunk(
|
|||||||
let tile_handle = mapper.unwrap().sample_tile(height);
|
let tile_handle = mapper.unwrap().sample_tile(height);
|
||||||
let tile = tiles.get(tile_handle).unwrap();
|
let tile = tiles.get(tile_handle).unwrap();
|
||||||
chunk.textures[idx] = [tile.texture_id, tile.side_texture_id];
|
chunk.textures[idx] = [tile.texture_id, tile.side_texture_id];
|
||||||
chunk.overlay_textures[idx] = tile.side_overlay_id;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ impl Plugin for DebugPlugin {
|
|||||||
.run_if(in_state(DebugState::Verbose)),
|
.run_if(in_state(DebugState::Verbose)),
|
||||||
);
|
);
|
||||||
|
|
||||||
app.add_systems(Update, camera_debug.in_set(GameplaySet));
|
// app.add_systems(Update, camera_debug.in_set(GameplaySet));
|
||||||
app.add_systems(Update, regenerate_map.run_if(in_state(GeneratorState::Idle)));
|
app.add_systems(Update, regenerate_map.run_if(in_state(GeneratorState::Idle)));
|
||||||
|
|
||||||
app.insert_resource(Shape(Polyline3d::new([
|
app.insert_resource(Shape(Polyline3d::new([
|
||||||
@@ -68,12 +68,7 @@ fn regenerate_map(
|
|||||||
fn show_tile_heights(map: Res<Map>, mut gizmos: Gizmos, shape: Res<Shape>, tile_under_cursor: Res<TileUnderCursor>) {
|
fn show_tile_heights(map: Res<Map>, mut gizmos: Gizmos, shape: Res<Shape>, tile_under_cursor: Res<TileUnderCursor>) {
|
||||||
if let Some(contact) = tile_under_cursor.0 {
|
if let Some(contact) = tile_under_cursor.0 {
|
||||||
let height = map.sample_height(&contact.tile);
|
let height = map.sample_height(&contact.tile);
|
||||||
gizmos.primitive_3d(
|
gizmos.primitive_3d(&shape.0, contact.tile.to_world(height + 0.01), Color::WHITE);
|
||||||
&shape.0,
|
|
||||||
contact.tile.to_world(height + 0.01),
|
|
||||||
Quat::IDENTITY,
|
|
||||||
Color::WHITE,
|
|
||||||
);
|
|
||||||
|
|
||||||
gizmos.line(contact.point, contact.point + Vec3::X, LinearRgba::RED);
|
gizmos.line(contact.point, contact.point + Vec3::X, LinearRgba::RED);
|
||||||
gizmos.line(contact.point, contact.point + Vec3::Y, LinearRgba::GREEN);
|
gizmos.line(contact.point, contact.point + Vec3::Y, LinearRgba::GREEN);
|
||||||
@@ -95,11 +90,11 @@ 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: Query<(&PhosCamera, &PhosOrbitCamera)>, mut gizmos: Gizmos) {
|
||||||
let (config, orbit) = cam_query.single();
|
let (config, orbit) = cam_query.single();
|
||||||
|
|
||||||
gizmos.sphere(orbit.target, Quat::IDENTITY, 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);
|
||||||
gizmos.ray(orbit.target, orbit.forward * 10.0, LinearRgba::rgb(1.0, 0.0, 1.0));
|
gizmos.ray(orbit.target, orbit.forward * 10.0, LinearRgba::rgb(1.0, 0.0, 1.0));
|
||||||
|
|
||||||
gizmos.circle(cam_proxy, Dir3::Y, 0.3, LinearRgba::rgb(1.0, 1.0, 0.0));
|
gizmos.circle(cam_proxy, 0.3, LinearRgba::rgb(1.0, 1.0, 0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn verbose_data() {}
|
fn verbose_data() {}
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ impl Plugin for EditorPlugin {
|
|||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.init_resource::<UIState>();
|
app.init_resource::<UIState>();
|
||||||
|
|
||||||
app.add_systems(PostUpdate, prepare_image.run_if(in_state(GeneratorState::SpawnMap)));
|
// app.add_systems(PostUpdate, prepare_image.run_if(in_state(GeneratorState::SpawnMap)));
|
||||||
app.add_systems(
|
// app.add_systems(
|
||||||
Update,
|
// Update,
|
||||||
(render_map_ui, update_map_render, asset_reloaded).run_if(in_state(GeneratorState::Idle)),
|
// (render_map_ui, update_map_render, asset_reloaded).run_if(in_state(GeneratorState::Idle)),
|
||||||
);
|
// );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ fn asset_reloaded(
|
|||||||
let mut rebuild = false;
|
let mut rebuild = false;
|
||||||
for event in asset_events.read() {
|
for event in asset_events.read() {
|
||||||
match event {
|
match event {
|
||||||
AssetEvent::Modified {..}=> rebuild = true,
|
AssetEvent::Modified { .. } => rebuild = true,
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
use bevy::{prelude::*, window::PrimaryWindow};
|
use bevy::{prelude::*, window::PrimaryWindow};
|
||||||
use bevy_rapier3d::{plugin::RapierContext, prelude::QueryFilter};
|
use bevy_rapier3d::{
|
||||||
|
plugin::{RapierContext, ReadDefaultRapierContext},
|
||||||
|
prelude::QueryFilter,
|
||||||
|
};
|
||||||
use shared::{
|
use shared::{
|
||||||
resources::{TileContact, TileUnderCursor},
|
resources::{TileContact, TileUnderCursor},
|
||||||
tags::MainCamera,
|
tags::MainCamera,
|
||||||
@@ -20,7 +23,7 @@ impl Plugin for TileSelectionPlugin {
|
|||||||
fn update_tile_under_cursor(
|
fn update_tile_under_cursor(
|
||||||
cam_query: Query<(&GlobalTransform, &Camera), With<MainCamera>>,
|
cam_query: Query<(&GlobalTransform, &Camera), With<MainCamera>>,
|
||||||
window: Query<&Window, With<PrimaryWindow>>,
|
window: Query<&Window, With<PrimaryWindow>>,
|
||||||
rapier_context: Res<RapierContext>,
|
rapier_context: ReadDefaultRapierContext,
|
||||||
map: Res<Map>,
|
map: Res<Map>,
|
||||||
mut tile_under_cursor: ResMut<TileUnderCursor>,
|
mut tile_under_cursor: ResMut<TileUnderCursor>,
|
||||||
) {
|
) {
|
||||||
@@ -35,7 +38,7 @@ fn update_tile_under_cursor(
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let Some(cam_ray) = camera.viewport_to_world(cam_transform, cursor_pos) else {
|
let Ok(cam_ray) = camera.viewport_to_world(cam_transform, cursor_pos) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.14.2"
|
bevy = "0.15.1"
|
||||||
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.204", features = ["derive"] }
|
||||||
asset_loader = { path = "../../engine/asset_loader" }
|
asset_loader = { path = "../../engine/asset_loader" }
|
||||||
serde_json = "1.0.120"
|
serde_json = "1.0.120"
|
||||||
ron = "0.8.1"
|
ron = "0.8.1"
|
||||||
bevy_asset_loader = { version = "0.21.0", features = [
|
bevy_asset_loader = { version = "0.22.0", features = [
|
||||||
"standard_dynamic_assets",
|
"standard_dynamic_assets",
|
||||||
"3d",
|
"3d",
|
||||||
] }
|
] }
|
||||||
|
|||||||
@@ -6,7 +6,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]
|
||||||
bevy = "0.14.2"
|
bevy = "0.15.1"
|
||||||
serde = { version = "1.0.204", features = ["derive"] }
|
serde = { version = "1.0.204", features = ["derive"] }
|
||||||
world_generation = { path = "../../engine/world_generation" }
|
world_generation = { path = "../../engine/world_generation" }
|
||||||
|
|
||||||
|
|||||||
18
game/shared/src/animation_plugin.rs
Normal file
18
game/shared/src/animation_plugin.rs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
use crate::prefab_defination::RotationAnimation;
|
||||||
|
|
||||||
|
pub struct SimpleAnimationPlugin;
|
||||||
|
|
||||||
|
impl Plugin for SimpleAnimationPlugin {
|
||||||
|
fn build(&self, app: &mut App) {
|
||||||
|
app.add_systems(Update, rotate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn rotate(mut query: Query<(&mut Transform, &RotationAnimation)>, time: Res<Time>) {
|
||||||
|
for (mut transform, rot) in query.iter_mut() {
|
||||||
|
let cur_rot = transform.rotation;
|
||||||
|
transform.rotation = cur_rot * Quat::from_axis_angle(rot.axis, rot.speed.to_radians() * time.delta_secs());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
|
use bevy::reflect::Reflect;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Default, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Default, Reflect, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct BuildingIdentifier(pub usize);
|
pub struct BuildingIdentifier(pub usize);
|
||||||
|
|
||||||
impl From<i32> for BuildingIdentifier {
|
impl From<i32> for BuildingIdentifier {
|
||||||
|
|||||||
20
game/shared/src/component_defination.rs
Normal file
20
game/shared/src/component_defination.rs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
use bevy::{
|
||||||
|
ecs::system::EntityCommands, math::{Quat, Vec3}, prelude::*
|
||||||
|
};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::prefab_defination::AnimationComponent;
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct ComponentDefination {
|
||||||
|
pub path: String,
|
||||||
|
pub animations: Vec<AnimationComponent>,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
impl ComponentDefination {
|
||||||
|
pub fn apply(&self, commands: &mut EntityCommands){
|
||||||
|
for c in &self.animations {
|
||||||
|
c.apply(commands);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ impl Plugin for DespawnPuglin {
|
|||||||
|
|
||||||
fn despawn_at(mut commands: Commands, time: Res<Time>, entities: Query<(Entity, &DespawnAt), Without<DespawnAfter>>) {
|
fn despawn_at(mut commands: Commands, time: Res<Time>, entities: Query<(Entity, &DespawnAt), Without<DespawnAfter>>) {
|
||||||
for (entity, at) in entities.iter() {
|
for (entity, at) in entities.iter() {
|
||||||
let d = at.0 - time.elapsed_seconds();
|
let d = at.0 - time.elapsed_secs();
|
||||||
commands
|
commands
|
||||||
.entity(entity)
|
.entity(entity)
|
||||||
.insert(DespawnAfter(Timer::from_seconds(d, TimerMode::Once)));
|
.insert(DespawnAfter(Timer::from_seconds(d, TimerMode::Once)));
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
use bevy::prelude::Resource;
|
use bevy::reflect::Reflect;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use world_generation::hex_utils::HexCoord;
|
use world_generation::hex_utils::HexCoord;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug, Reflect)]
|
||||||
pub struct ResourceIdentifier {
|
pub struct ResourceIdentifier {
|
||||||
pub id: u32,
|
pub id: u32,
|
||||||
pub qty: u32,
|
pub qty: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Reflect)]
|
||||||
|
pub struct UnitIdentifier(u32);
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Reflect)]
|
||||||
|
pub struct TileIdentifier(u32);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use bevy::reflect::Reflect;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub mod building;
|
pub mod building;
|
||||||
@@ -8,6 +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 component_defination;
|
||||||
|
pub mod animation_plugin;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub enum Tier {
|
pub enum Tier {
|
||||||
@@ -17,3 +21,17 @@ pub enum Tier {
|
|||||||
Three,
|
Three,
|
||||||
Superior,
|
Superior,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Reflect)]
|
||||||
|
pub enum StatusEffect {
|
||||||
|
UnitRange(f32),
|
||||||
|
UnitAttack(f32),
|
||||||
|
UnitHealth(f32),
|
||||||
|
StructureRange(f32),
|
||||||
|
StructureAttack(f32),
|
||||||
|
StructureHealth(f32),
|
||||||
|
BuildSpeedMulti(f32),
|
||||||
|
BuildCostMulti(f32),
|
||||||
|
ConsumptionMulti(f32),
|
||||||
|
ProductionMulti(f32),
|
||||||
|
}
|
||||||
|
|||||||
79
game/shared/src/prefab_defination.rs
Normal file
79
game/shared/src/prefab_defination.rs
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
use bevy::{
|
||||||
|
ecs::system::{EntityCommand, EntityCommands},
|
||||||
|
gltf::{Gltf, GltfMesh},
|
||||||
|
math::{Quat, Vec3},
|
||||||
|
prelude::*,
|
||||||
|
};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct PrefabDefination {
|
||||||
|
pub path: String,
|
||||||
|
pub pos: Vec3,
|
||||||
|
pub rot: Vec3,
|
||||||
|
pub children: Option<Vec<PrefabDefination>>,
|
||||||
|
pub animations: Option<Vec<AnimationComponent>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PrefabDefination {
|
||||||
|
pub fn spawn_recursive(&self, gltf: &Gltf, commands: &mut ChildBuilder, meshes: &Assets<GltfMesh>) {
|
||||||
|
let mesh_handle = &gltf.named_meshes[&self.path.clone().into_boxed_str()];
|
||||||
|
if let Some(gltf_mesh) = meshes.get(mesh_handle.id()) {
|
||||||
|
let (m, mat) = gltf_mesh.unpack();
|
||||||
|
let mut entity = commands.spawn((
|
||||||
|
Mesh3d(m),
|
||||||
|
MeshMaterial3d(mat),
|
||||||
|
Transform::from_translation(self.pos).with_rotation(Quat::from_euler(
|
||||||
|
bevy::math::EulerRot::XYZ,
|
||||||
|
self.rot.x,
|
||||||
|
self.rot.y,
|
||||||
|
self.rot.z,
|
||||||
|
)),
|
||||||
|
));
|
||||||
|
if let Some(children) = &self.children {
|
||||||
|
entity.with_children(|b| {
|
||||||
|
for child in children {
|
||||||
|
child.spawn_recursive(gltf, b, meshes);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait UnpackGltfMesh {
|
||||||
|
fn unpack(&self) -> (Handle<Mesh>, Handle<StandardMaterial>);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl UnpackGltfMesh for GltfMesh {
|
||||||
|
fn unpack(&self) -> (Handle<Mesh>, Handle<StandardMaterial>) {
|
||||||
|
let p = &self.primitives[0];
|
||||||
|
let mut mat: Handle<StandardMaterial> = default();
|
||||||
|
if let Some(mesh_material) = &p.material {
|
||||||
|
mat = mesh_material.clone();
|
||||||
|
}
|
||||||
|
return (p.mesh.clone(), mat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub enum AnimationComponent {
|
||||||
|
Rotation(RotationAnimation),
|
||||||
|
Slider,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Component, Clone, Copy)]
|
||||||
|
pub struct RotationAnimation {
|
||||||
|
pub axis: Vec3,
|
||||||
|
pub speed: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AnimationComponent {
|
||||||
|
pub fn apply(&self, commands: &mut EntityCommands) {
|
||||||
|
match self {
|
||||||
|
AnimationComponent::Rotation(comp) => {
|
||||||
|
commands.insert(comp.clone());
|
||||||
|
}
|
||||||
|
AnimationComponent::Slider => todo!(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,15 +4,15 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.14.2"
|
bevy = "0.15.1"
|
||||||
world_generation = { path = "../../engine/world_generation" }
|
world_generation = { path = "../../engine/world_generation" }
|
||||||
shared = { path = "../shared" }
|
shared = { path = "../shared" }
|
||||||
bevy_rapier3d = "0.27.0"
|
bevy_rapier3d = "0.28.0"
|
||||||
serde = { version = "1.0.204", features = ["derive"] }
|
serde = { version = "1.0.204", features = ["derive"] }
|
||||||
asset_loader = { path = "../../engine/asset_loader" }
|
asset_loader = { path = "../../engine/asset_loader" }
|
||||||
serde_json = "1.0.120"
|
serde_json = "1.0.120"
|
||||||
ron = "0.8.1"
|
ron = "0.8.1"
|
||||||
bevy_asset_loader = { version = "0.21.0", features = [
|
bevy_asset_loader = { version = "0.22.0", features = [
|
||||||
"standard_dynamic_assets",
|
"standard_dynamic_assets",
|
||||||
"3d",
|
"3d",
|
||||||
] }
|
] }
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use bevy::reflect::Reflect;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub mod assets;
|
pub mod assets;
|
||||||
pub mod components;
|
pub mod components;
|
||||||
|
|||||||
@@ -34,11 +34,7 @@ fn spawn_test_unit(
|
|||||||
if let Some(contact) = tile_under_cursor.0 {
|
if let Some(contact) = tile_under_cursor.0 {
|
||||||
info!("Spawning Test Unit");
|
info!("Spawning Test Unit");
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
PbrBundle {
|
(Transform::from_translation(contact.surface), Mesh3d(unit.0.clone())),
|
||||||
transform: Transform::from_translation(contact.surface),
|
|
||||||
mesh: unit.0.clone(),
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
Unit,
|
Unit,
|
||||||
LandUnit,
|
LandUnit,
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ fn move_unit(
|
|||||||
path.1 += 1;
|
path.1 += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let vel = d.normalize() * 10.0 * time.delta_seconds();
|
let vel = d.normalize() * 10.0 * time.delta_secs();
|
||||||
t.translation += vel;
|
t.translation += vel;
|
||||||
let coord = HexCoord::from_world_pos(t.translation);
|
let coord = HexCoord::from_world_pos(t.translation);
|
||||||
if map.is_in_bounds(&coord) {
|
if map.is_in_bounds(&coord) {
|
||||||
|
|||||||
Reference in New Issue
Block a user