Compare commits
1 Commits
lunex
...
overlay-te
| Author | SHA1 | Date | |
|---|---|---|---|
| 33fa18fe97 |
185
Cargo.lock
generated
185
Cargo.lock
generated
@@ -745,30 +745,6 @@ dependencies = [
|
||||
"encase_derive_impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_eventlistener"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63aff74ac1477b88b57ff2f82fc711a7931414be7ee7d0e96aeea45b6d4a7cb6"
|
||||
dependencies = [
|
||||
"bevy_app",
|
||||
"bevy_ecs",
|
||||
"bevy_eventlistener_derive",
|
||||
"bevy_hierarchy",
|
||||
"bevy_utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_eventlistener_derive"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fc779559aa23b81da2b14fba90586755d225983c5b6d3154658e42fc088de7f"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.86",
|
||||
"quote 1.0.36",
|
||||
"syn 2.0.70",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_gilrs"
|
||||
version = "0.14.2"
|
||||
@@ -937,18 +913,6 @@ dependencies = [
|
||||
"tracing-wasm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_lunex"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32e2bb6bf7507c23bb69edf4f045312448b8dbba73b85dda58e9178255ece099"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"bevy_mod_picking",
|
||||
"colored",
|
||||
"lunex_engine",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_macro_utils"
|
||||
version = "0.14.2"
|
||||
@@ -984,48 +948,6 @@ dependencies = [
|
||||
"glam",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_mod_picking"
|
||||
version = "0.20.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e290b8ad3e72dc621da7a9c21129da10540d78290ef8857353190e0213cac692"
|
||||
dependencies = [
|
||||
"bevy_app",
|
||||
"bevy_core",
|
||||
"bevy_ecs",
|
||||
"bevy_eventlistener",
|
||||
"bevy_math",
|
||||
"bevy_picking_core",
|
||||
"bevy_picking_highlight",
|
||||
"bevy_picking_input",
|
||||
"bevy_picking_raycast",
|
||||
"bevy_picking_selection",
|
||||
"bevy_reflect",
|
||||
"bevy_render",
|
||||
"bevy_utils",
|
||||
"bevy_window",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_mod_raycast"
|
||||
version = "0.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9e4ff45885c4716771a9f55977d8ce69596502a5241da55bf608d7cd71a9cb3"
|
||||
dependencies = [
|
||||
"bevy_app",
|
||||
"bevy_asset",
|
||||
"bevy_color",
|
||||
"bevy_derive",
|
||||
"bevy_ecs",
|
||||
"bevy_math",
|
||||
"bevy_reflect",
|
||||
"bevy_render",
|
||||
"bevy_transform",
|
||||
"bevy_utils",
|
||||
"bevy_window",
|
||||
"crossbeam-channel",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_pbr"
|
||||
version = "0.14.2"
|
||||
@@ -1053,90 +975,6 @@ dependencies = [
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_picking_core"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "020b6cf6079927a1e6a3dd883986546632d8d09ab77840997f4936a74eade722"
|
||||
dependencies = [
|
||||
"bevy_app",
|
||||
"bevy_derive",
|
||||
"bevy_ecs",
|
||||
"bevy_eventlistener",
|
||||
"bevy_math",
|
||||
"bevy_reflect",
|
||||
"bevy_render",
|
||||
"bevy_transform",
|
||||
"bevy_utils",
|
||||
"bevy_window",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_picking_highlight"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ba45161608da1bb58cbc55fd83cf5e529e616a180778c394733c85056cd2b76"
|
||||
dependencies = [
|
||||
"bevy_app",
|
||||
"bevy_asset",
|
||||
"bevy_color",
|
||||
"bevy_ecs",
|
||||
"bevy_picking_core",
|
||||
"bevy_picking_selection",
|
||||
"bevy_reflect",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_picking_input"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ba8cf67c68a5e150c066366744f9a44006ead9ad280de1c9ca69a6a13c5e283"
|
||||
dependencies = [
|
||||
"bevy_app",
|
||||
"bevy_ecs",
|
||||
"bevy_hierarchy",
|
||||
"bevy_input",
|
||||
"bevy_math",
|
||||
"bevy_picking_core",
|
||||
"bevy_picking_selection",
|
||||
"bevy_reflect",
|
||||
"bevy_render",
|
||||
"bevy_utils",
|
||||
"bevy_window",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_picking_raycast"
|
||||
version = "0.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b024e7b0a6062aafd5daa746e5298a1b726c6409de11e35e0b574b712ebda3d"
|
||||
dependencies = [
|
||||
"bevy_app",
|
||||
"bevy_ecs",
|
||||
"bevy_mod_raycast",
|
||||
"bevy_picking_core",
|
||||
"bevy_reflect",
|
||||
"bevy_render",
|
||||
"bevy_transform",
|
||||
"bevy_window",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_picking_selection"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf0769d84e944fbc09b0475f068e5232a8a4be15339796539aecd747413ededd"
|
||||
dependencies = [
|
||||
"bevy_app",
|
||||
"bevy_ecs",
|
||||
"bevy_eventlistener",
|
||||
"bevy_input",
|
||||
"bevy_picking_core",
|
||||
"bevy_reflect",
|
||||
"bevy_utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_ptr"
|
||||
version = "0.14.2"
|
||||
@@ -1770,16 +1608,6 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
||||
|
||||
[[package]]
|
||||
name = "colored"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "com"
|
||||
version = "0.6.0"
|
||||
@@ -3251,18 +3079,6 @@ dependencies = [
|
||||
"imgref",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lunex_engine"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64d55d2e631c0eb2d5bc164ca826452f550a57a9b0d8da93e6e5625d23f533bd"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"colored",
|
||||
"indexmap",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mach2"
|
||||
version = "0.4.2"
|
||||
@@ -4150,7 +3966,6 @@ dependencies = [
|
||||
"bevy",
|
||||
"bevy-inspector-egui",
|
||||
"bevy_asset_loader",
|
||||
"bevy_lunex",
|
||||
"bevy_rapier3d",
|
||||
"buildings",
|
||||
"image 0.25.2",
|
||||
|
||||
@@ -41,9 +41,9 @@ pub const HEX_NORMALS: [Vec3; 6] = [
|
||||
];
|
||||
|
||||
pub const ATTRIBUTE_PACKED_VERTEX_DATA: MeshVertexAttribute =
|
||||
MeshVertexAttribute::new("PackedVertexData", 7, VertexFormat::Uint32);
|
||||
MeshVertexAttribute::new("PackedVertexData", 988540817, VertexFormat::Uint32);
|
||||
pub const ATTRIBUTE_VERTEX_HEIGHT: MeshVertexAttribute =
|
||||
MeshVertexAttribute::new("VertexHeight", 8, VertexFormat::Float32);
|
||||
MeshVertexAttribute::new("VertexHeight", 988540717, VertexFormat::Float32);
|
||||
|
||||
pub const ATTRIBUTE_TEXTURE_INDEX: MeshVertexAttribute =
|
||||
MeshVertexAttribute::new("TextureIndex", 988540917, VertexFormat::Uint32);
|
||||
|
||||
@@ -39,6 +39,7 @@ pub fn generate_chunk_mesh(chunk: &MeshChunkData) -> Mesh {
|
||||
// &mut tex,
|
||||
chunk.textures[idx][0],
|
||||
chunk.textures[idx][1],
|
||||
chunk.overlay_textures[idx],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -63,10 +64,14 @@ fn create_tile(
|
||||
normals: &mut Vec<Vec3>,
|
||||
texture_index: u32,
|
||||
side_texture_index: u32,
|
||||
side_overlay_texture_index: Option<u32>,
|
||||
) {
|
||||
let uv_offset = Vec2::splat(0.5);
|
||||
let tex_off = Vec2::new(texture_index as f32, 0.);
|
||||
let side_tex_off = Vec2::new(side_texture_index as f32, 0.);
|
||||
let side_tex_off = Vec2::new(
|
||||
pack_texture_data(side_texture_index, side_overlay_texture_index) as f32,
|
||||
0.,
|
||||
);
|
||||
|
||||
let idx = verts.len() as u32;
|
||||
for i in 0..6 {
|
||||
@@ -278,6 +283,13 @@ fn create_tile_wall(
|
||||
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)]
|
||||
mod tests {
|
||||
|
||||
@@ -320,7 +332,17 @@ mod tests {
|
||||
//4 side faces
|
||||
let nbors = [2.0, 2.0, 0.0, 0.0, 0.0, 0.0];
|
||||
|
||||
create_tile(Vec3::Y, &nbors, &mut verts, &mut uvs, &mut indices, &mut normals, 3, 7);
|
||||
create_tile(
|
||||
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!(uvs.len() == (6 + 4 * 4), "Number of uvs don't match");
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
use crate::hex_utils::{offset3d_to_world, HexCoord};
|
||||
use crate::hex_utils::HexCoord;
|
||||
use crate::map::biome_map::BiomeChunk;
|
||||
use crate::prelude::*;
|
||||
use crate::tile_manager::TileAsset;
|
||||
use crate::tile_mapper::TileMapperAsset;
|
||||
use crate::{biome_asset::BiomeAsset, biome_painter::BiomePainterAsset};
|
||||
use bevy::{
|
||||
prelude::*,
|
||||
render::{
|
||||
@@ -8,7 +12,15 @@ use bevy::{
|
||||
},
|
||||
};
|
||||
|
||||
pub fn generate_packed_chunk_mesh(chunk: &MeshChunkData) -> Mesh {
|
||||
pub fn generate_packed_chunk_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 mut packed_data = Vec::with_capacity(vertex_count);
|
||||
let mut indices = Vec::with_capacity(vertex_count);
|
||||
@@ -16,10 +28,16 @@ pub fn generate_packed_chunk_mesh(chunk: &MeshChunkData) -> Mesh {
|
||||
|
||||
for z in 0..Chunk::SIZE {
|
||||
for x in 0..Chunk::SIZE {
|
||||
let idx = x + z * Chunk::SIZE;
|
||||
let height = chunk.heights[idx];
|
||||
let coord = HexCoord::from_grid_pos(x, z);
|
||||
let n = chunk.get_neighbors(&coord);
|
||||
let height = chunk.heights[x + z * Chunk::SIZE];
|
||||
let data = biome_chunk.data[x + z * Chunk::SIZE];
|
||||
let coord =
|
||||
HexCoord::from_offset(IVec2::new(x as i32, z as i32) + (chunk.chunk_offset * Chunk::SIZE as i32));
|
||||
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(
|
||||
UVec2::new(x as u32, z as u32),
|
||||
@@ -28,8 +46,8 @@ pub fn generate_packed_chunk_mesh(chunk: &MeshChunkData) -> Mesh {
|
||||
&mut packed_data,
|
||||
&mut indices,
|
||||
&mut heights,
|
||||
chunk.textures[idx][0],
|
||||
chunk.textures[idx][1],
|
||||
tile.texture_id,
|
||||
tile.side_texture_id,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -47,7 +65,7 @@ pub fn generate_packed_chunk_mesh(chunk: &MeshChunkData) -> Mesh {
|
||||
fn create_packed_tile(
|
||||
offset: UVec2,
|
||||
height: f32,
|
||||
neighbors: &[f32; 6],
|
||||
neighbors: &[Option<f32>; 6],
|
||||
packed_data: &mut Vec<u32>,
|
||||
indices: &mut Vec<u32>,
|
||||
heights: &mut Vec<f32>,
|
||||
@@ -67,18 +85,23 @@ fn create_packed_tile(
|
||||
}
|
||||
|
||||
for i in 0..neighbors.len() {
|
||||
let n_height = neighbors[i];
|
||||
if n_height < height {
|
||||
create_packed_tile_wall(
|
||||
offset,
|
||||
height,
|
||||
n_height,
|
||||
i,
|
||||
packed_data,
|
||||
indices,
|
||||
heights,
|
||||
side_texture_index,
|
||||
);
|
||||
let cur_n = neighbors[i];
|
||||
match cur_n {
|
||||
Some(n_height) => {
|
||||
if n_height < height {
|
||||
create_packed_tile_wall(
|
||||
offset,
|
||||
height,
|
||||
n_height,
|
||||
i,
|
||||
packed_data,
|
||||
indices,
|
||||
heights,
|
||||
side_texture_index,
|
||||
);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use crate::hex_utils::SHORT_DIAGONAL;
|
||||
use bevy::prelude::*;
|
||||
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Chunk {
|
||||
pub heights: [f32; Chunk::AREA],
|
||||
pub textures: [[u32; 2]; Chunk::AREA],
|
||||
pub overlay_textures: [Option<u32>; Chunk::AREA],
|
||||
// pub biome_data: [BiomeData; Chunk::AREA],
|
||||
pub biome_id: [usize; Chunk::AREA],
|
||||
pub chunk_offset: IVec2,
|
||||
@@ -18,6 +18,7 @@ impl Default for Chunk {
|
||||
Self {
|
||||
heights: [0.; Chunk::AREA],
|
||||
textures: [[0; 2]; Chunk::AREA],
|
||||
overlay_textures: [None; Chunk::AREA],
|
||||
// biome_data: [BiomeData::default(); Chunk::AREA],
|
||||
biome_id: [0; Chunk::AREA],
|
||||
chunk_offset: Default::default(),
|
||||
|
||||
@@ -2,10 +2,7 @@ use bevy::prelude::*;
|
||||
|
||||
use crate::hex_utils::*;
|
||||
|
||||
use super::{
|
||||
chunk::Chunk,
|
||||
mesh_chunk::MeshChunkData,
|
||||
};
|
||||
use super::{chunk::Chunk, mesh_chunk::MeshChunkData};
|
||||
|
||||
#[derive(Resource, Clone)]
|
||||
pub struct Map {
|
||||
@@ -41,6 +38,7 @@ impl Map {
|
||||
sealevel: self.sealevel,
|
||||
heights: chunk.heights.clone(),
|
||||
textures: chunk.textures.clone(),
|
||||
overlay_textures: chunk.overlay_textures.clone(),
|
||||
distance_to_land: self.get_distance_from_land(chunk.chunk_offset, 4),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use super::chunk::Chunk;
|
||||
pub struct MeshChunkData {
|
||||
pub heights: [f32; Chunk::AREA],
|
||||
pub textures: [[u32; 2]; Chunk::AREA],
|
||||
pub overlay_textures: [Option<u32>; Chunk::AREA],
|
||||
pub min_height: f32,
|
||||
pub sealevel: f32,
|
||||
pub distance_to_land: [f32; Chunk::AREA],
|
||||
|
||||
@@ -29,6 +29,7 @@ pub struct TileAsset {
|
||||
#[serde(skip)]
|
||||
pub texture: String,
|
||||
pub side_texture_id: u32,
|
||||
pub side_overlay_id: Option<u32>,
|
||||
#[serde(skip)]
|
||||
pub side_texture: String,
|
||||
}
|
||||
|
||||
@@ -3,13 +3,7 @@ use bevy::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use shared::identifiers::ResourceIdentifier;
|
||||
|
||||
use crate::{
|
||||
buildings::{
|
||||
basic_building::BasicBuildingInfo, factory_building::FactoryBuildingInfo,
|
||||
resource_gathering::ResourceGatheringBuildingInfo,
|
||||
},
|
||||
footprint::BuildingFootprint,
|
||||
};
|
||||
use crate::footprint::BuildingFootprint;
|
||||
|
||||
#[derive(Asset, TypePath, Debug, Serialize, Deserialize)]
|
||||
pub struct BuildingAsset {
|
||||
@@ -23,25 +17,8 @@ pub struct BuildingAsset {
|
||||
pub cost: Vec<ResourceIdentifier>,
|
||||
pub consumption: Vec<ResourceIdentifier>,
|
||||
pub production: Vec<ResourceIdentifier>,
|
||||
|
||||
pub health: u32,
|
||||
|
||||
pub building_type: BuildingType,
|
||||
pub animations: Vec<AnimationComponent>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, TypePath)]
|
||||
pub enum BuildingType {
|
||||
Basic,
|
||||
Gathering(ResourceGatheringBuildingInfo),
|
||||
FactoryBuildingInfo(FactoryBuildingInfo),
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Reflect)]
|
||||
pub enum AnimationComponent {
|
||||
Rotation,
|
||||
Slider,
|
||||
}
|
||||
create_asset_loader!(
|
||||
BuildingAssetPlugin,
|
||||
BuildingAssetLoader,
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use shared::identifiers::ResourceIdentifier;
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct BasicBuildingInfo {}
|
||||
@@ -1,6 +0,0 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct FactoryBuildingInfo {
|
||||
pub units_to_build: Vec<()>
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
pub mod resource_gathering;
|
||||
pub mod basic_building;
|
||||
pub mod factory_building;
|
||||
pub mod tech_building;
|
||||
@@ -1,8 +0,0 @@
|
||||
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,
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
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,5 +4,4 @@ pub mod building_plugin;
|
||||
pub mod buildings_map;
|
||||
pub mod footprint;
|
||||
pub mod prelude;
|
||||
mod buildings;
|
||||
pub use building_plugin::*;
|
||||
|
||||
@@ -27,7 +27,6 @@ bevy_asset_loader = { version = "0.21.0", features = [
|
||||
] }
|
||||
ron = "0.8.1"
|
||||
image = "0.25.2"
|
||||
bevy_lunex = "0.2.4"
|
||||
|
||||
[features]
|
||||
tracing = [
|
||||
|
||||
Submodule game/main/assets updated: 4082df18e0...67cf2d46ce
@@ -2,9 +2,7 @@ use bevy::core_pipeline::experimental::taa::{TemporalAntiAliasBundle, TemporalAn
|
||||
use bevy::core_pipeline::prepass::DepthPrepass;
|
||||
use bevy::input::mouse::{MouseMotion, MouseScrollUnit, MouseWheel};
|
||||
use bevy::prelude::*;
|
||||
use bevy::render::view::RenderLayers;
|
||||
use bevy::window::{CursorGrabMode, PrimaryWindow};
|
||||
use bevy_lunex::prelude::MainUi;
|
||||
use shared::sets::GameplaySet;
|
||||
use shared::tags::MainCamera;
|
||||
use world_generation::hex_utils::HexCoord;
|
||||
@@ -61,10 +59,8 @@ fn setup(mut commands: Commands, mut msaa: ResMut<Msaa>) {
|
||||
MainCamera,
|
||||
DepthPrepass,
|
||||
PhosOrbitCamera::default(),
|
||||
MainUi,
|
||||
))
|
||||
.insert(TemporalAntiAliasBundle::default())
|
||||
.insert(RenderLayers::layer(0));
|
||||
.insert(TemporalAntiAliasBundle::default());
|
||||
|
||||
*msaa = Msaa::Off;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ impl Default for PhosCamera {
|
||||
max_height: 420.,
|
||||
speed: 100.,
|
||||
pan_speed: Vec2::new(0.8, 0.5),
|
||||
zoom_speed: 20.,
|
||||
zoom_speed: 200.,
|
||||
min_angle: (20. as f32).to_radians(),
|
||||
max_angle: 1.,
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use std::env;
|
||||
|
||||
use bevy::pbr::wireframe::WireframePlugin;
|
||||
use bevy::prelude::*;
|
||||
use bevy::render::texture::{ImageAddressMode, ImageFilterMode, ImageSamplerDescriptor};
|
||||
@@ -12,8 +10,8 @@ mod map_rendering;
|
||||
mod phos;
|
||||
mod prelude;
|
||||
mod shader_extensions;
|
||||
mod ui;
|
||||
mod utlis;
|
||||
mod ui;
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
|
||||
@@ -3,7 +3,6 @@ use bevy::log::*;
|
||||
use bevy::{
|
||||
pbr::{ExtendedMaterial, NotShadowCaster},
|
||||
prelude::*,
|
||||
render::render_resource::{ColorTargetState, FragmentState, RenderPipelineDescriptor},
|
||||
};
|
||||
use bevy_asset_loader::prelude::*;
|
||||
|
||||
@@ -220,7 +219,6 @@ fn spawn_map(
|
||||
) {
|
||||
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 chunk_meshes: Vec<_> = heightmap
|
||||
.chunks
|
||||
@@ -238,8 +236,6 @@ fn spawn_map(
|
||||
.collect();
|
||||
|
||||
let mut registry = PhosChunkRegistry::new(chunk_meshes.len());
|
||||
|
||||
//Spawn Chunks
|
||||
{
|
||||
#[cfg(feature = "tracing")]
|
||||
let _spawn_span = info_span!("Spawn Chunks").entered();
|
||||
@@ -281,6 +277,20 @@ 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);
|
||||
generator_state.set(GeneratorState::Idle);
|
||||
if cur_game_state.get() != &MenuState::InGame {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use bevy::prelude::*;
|
||||
use shared::tags::MainCamera;
|
||||
|
||||
use crate::camera_system::components::PhosCamera;
|
||||
|
||||
@@ -53,7 +52,7 @@ impl Default for RenderDistanceVisibility {
|
||||
|
||||
fn render_distance_system(
|
||||
mut objects: Query<(&Transform, &mut Visibility, &RenderDistanceVisibility)>,
|
||||
camera_query: Query<&Transform, With<MainCamera>>,
|
||||
camera_query: Query<&Transform, With<PhosCamera>>,
|
||||
settings: Res<RenderDistanceSettings>,
|
||||
) {
|
||||
let camera = camera_query.single();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use crate::camera_system::components::PhosCamera;
|
||||
use crate::map_rendering::map_init::MapInitPlugin;
|
||||
use crate::map_rendering::render_distance_system::RenderDistancePlugin;
|
||||
use crate::ui::game::build_ui::BuildUiPlugin;
|
||||
use crate::utlis::editor_plugin::EditorPlugin;
|
||||
use crate::utlis::tile_selection_plugin::TileSelectionPlugin;
|
||||
use crate::{camera_system::camera_plugin::PhosCameraPlugin, utlis::debug_plugin::DebugPlugin};
|
||||
@@ -38,7 +37,6 @@ impl Plugin for PhosGamePlugin {
|
||||
MapInitPlugin,
|
||||
RenderDistancePlugin,
|
||||
BuildingPugin,
|
||||
BuildUiPlugin,
|
||||
UnitsPlugin,
|
||||
DespawnPuglin,
|
||||
TileSelectionPlugin,
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
use bevy::asset::{Asset, Handle};
|
||||
use bevy::pbr::{Material, MaterialExtension};
|
||||
use bevy::pbr::MaterialExtension;
|
||||
use bevy::reflect::TypePath;
|
||||
use bevy::render::mesh::{MeshVertexAttribute, MeshVertexBufferLayoutRef};
|
||||
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)]
|
||||
pub struct ChunkMaterial {
|
||||
@@ -17,50 +15,25 @@ impl MaterialExtension for ChunkMaterial {
|
||||
fn fragment_shader() -> ShaderRef {
|
||||
"shaders/world/chunk.wgsl".into()
|
||||
}
|
||||
}
|
||||
|
||||
#[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 {
|
||||
// fn vertex_shader() -> ShaderRef {
|
||||
// "shaders/world/chunk_packed.wgsl".into()
|
||||
// }
|
||||
|
||||
// fn opaque_render_method(&self) -> bevy::pbr::OpaqueRendererMethod {
|
||||
// return OpaqueRendererMethod::Auto;
|
||||
// fn specialize(
|
||||
// _pipeline: &bevy::pbr::MaterialExtensionPipeline,
|
||||
// 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(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +1,11 @@
|
||||
use bevy::{prelude::*, render::view::RenderLayers};
|
||||
use bevy_lunex::prelude::*;
|
||||
use shared::tags::MainCamera;
|
||||
use bevy::prelude::*;
|
||||
|
||||
pub struct BuildUiPlugin;
|
||||
|
||||
impl Plugin for BuildUiPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
// app.add_plugins(UiDefaultPlugins)
|
||||
// .add_plugins(UiDebugPlugin::<MainUi>::new());
|
||||
|
||||
app.add_systems(PostStartup, setup_ui);
|
||||
app.add_systems(PostStartup, setup);
|
||||
}
|
||||
}
|
||||
|
||||
fn setup_ui(mut commands: Commands, assets: Res<AssetServer>) {
|
||||
commands
|
||||
.spawn((
|
||||
Camera2dBundle {
|
||||
transform: Transform::from_xyz(0.0, 0.0, 1000.0),
|
||||
..default()
|
||||
},
|
||||
MainUi,
|
||||
))
|
||||
.insert(RenderLayers::layer(1));
|
||||
|
||||
commands
|
||||
.spawn((
|
||||
UiTreeBundle::<MainUi> {
|
||||
tree: UiTree::new2d("BuildUi"),
|
||||
..default()
|
||||
},
|
||||
Name::new("Build UI"),
|
||||
SourceFromCamera,
|
||||
RenderLayers::layer(1),
|
||||
))
|
||||
.with_children(|ui| {
|
||||
ui.spawn((
|
||||
UiLink::<MainUi>::path("Root"),
|
||||
UiLayout::boundary()
|
||||
.pos1(Ab(20.0))
|
||||
.pos2(Rl(100.0) - Ab(20.0))
|
||||
.pack::<Base>(),
|
||||
RenderLayers::layer(1),
|
||||
));
|
||||
|
||||
ui.spawn((
|
||||
UiLink::<MainUi>::path("Root/Rect"),
|
||||
UiLayout::solid().size((Ab(1920.0), Ab(1080.0))).pack::<Base>(),
|
||||
UiImage2dBundle::from(assets.load("textures/world/test2.png")),
|
||||
RenderLayers::layer(1),
|
||||
));
|
||||
});
|
||||
}
|
||||
fn setup(mut commands: Commands) {}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
pub mod build_ui;
|
||||
|
||||
pub mod build_ui;
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
|
||||
pub mod game;
|
||||
|
||||
@@ -13,7 +13,6 @@ use world_generation::{
|
||||
generators::{
|
||||
chunk_colliders::generate_chunk_collider,
|
||||
mesh_generator::{generate_chunk_mesh, generate_chunk_water_mesh},
|
||||
packed_mesh_generator::generate_packed_chunk_mesh,
|
||||
},
|
||||
hex_utils::offset_to_world,
|
||||
prelude::{Chunk, Map, MeshChunkData},
|
||||
@@ -48,6 +47,7 @@ pub fn paint_chunk(
|
||||
let tile_handle = mapper.unwrap().sample_tile(height);
|
||||
let tile = tiles.get(tile_handle).unwrap();
|
||||
chunk.textures[idx] = [tile.texture_id, tile.side_texture_id];
|
||||
chunk.overlay_textures[idx] = tile.side_overlay_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use bevy::reflect::Reflect;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Default, Reflect, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct BuildingIdentifier(pub usize);
|
||||
|
||||
impl From<i32> for BuildingIdentifier {
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
use bevy::reflect::Reflect;
|
||||
use bevy::prelude::Resource;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use world_generation::hex_utils::HexCoord;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Reflect)]
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct ResourceIdentifier {
|
||||
pub id: u32,
|
||||
pub qty: u32,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Reflect)]
|
||||
pub struct UnitIdentifier(u32);
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Reflect)]
|
||||
pub struct TileIdentifier(u32);
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use bevy::reflect::Reflect;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub mod building;
|
||||
@@ -18,17 +17,3 @@ pub enum Tier {
|
||||
Three,
|
||||
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),
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use bevy::reflect::Reflect;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub mod assets;
|
||||
pub mod components;
|
||||
|
||||
Reference in New Issue
Block a user