misc
This commit is contained in:
10
Cargo.lock
generated
10
Cargo.lock
generated
@@ -1327,6 +1327,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"bevy_rapier3d",
|
||||
"serde",
|
||||
"shared",
|
||||
"world_generation",
|
||||
]
|
||||
@@ -3745,18 +3746,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.197"
|
||||
version = "1.0.203"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"
|
||||
checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.197"
|
||||
version = "1.0.203"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
|
||||
checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -3788,6 +3789,7 @@ name = "shared"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -6,6 +6,6 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
serde = "1.0.197"
|
||||
serde = "1.0.203"
|
||||
serde_json = "1.0.115"
|
||||
bevy = "0.13.2"
|
||||
|
||||
@@ -8,7 +8,7 @@ edition = "2021"
|
||||
[dependencies]
|
||||
bevy = "0.13.2"
|
||||
noise = "0.9.0"
|
||||
serde = {version="1.0.197", features=["derive"]}
|
||||
serde = {version="1.0.203", features=["derive"]}
|
||||
serde_json = "1.0.115"
|
||||
asset_loader = {path = "../asset_loader"}
|
||||
rayon = "1.10.0"
|
||||
|
||||
@@ -10,6 +10,7 @@ bevy = "0.13.2"
|
||||
world_generation = {path = "../../engine/world_generation"}
|
||||
shared = {path = "../shared"}
|
||||
bevy_rapier3d = "0.26.0"
|
||||
serde = {version="1.0.203", features=["derive"]}
|
||||
|
||||
[features]
|
||||
tracing = []
|
||||
|
||||
18
game/buildings/src/assets/building_asset.rs
Normal file
18
game/buildings/src/assets/building_asset.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
use bevy::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use shared::resource::ResourceIdentifier;
|
||||
|
||||
use crate::footprint::BuildingFootprint;
|
||||
|
||||
#[derive(Resource, Serialize, Deserialize)]
|
||||
pub struct BuildingAsset {
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub footprint: BuildingFootprint,
|
||||
pub prefab_path: String,
|
||||
pub prefab: (),
|
||||
|
||||
pub cost: Vec<ResourceIdentifier>,
|
||||
pub consumption: Vec<ResourceIdentifier>,
|
||||
pub production: Vec<ResourceIdentifier>,
|
||||
}
|
||||
1
game/buildings/src/assets/mod.rs
Normal file
1
game/buildings/src/assets/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub mod building_asset;
|
||||
32
game/buildings/src/footprint.rs
Normal file
32
game/buildings/src/footprint.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use bevy::math::{IVec2, Vec3Swizzles};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use world_generation::hex_utils::HexCoord;
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct BuildingFootprint {
|
||||
pub footprint: Vec<IVec2>,
|
||||
}
|
||||
|
||||
impl BuildingFootprint {
|
||||
pub fn get_footprint(&self, center: &HexCoord) -> Vec<HexCoord> {
|
||||
let c = center.hex.xy();
|
||||
return self.footprint.iter().map(|p| HexCoord::from_hex(*p + c)).collect();
|
||||
}
|
||||
|
||||
pub fn get_footprint_rotated(&self, center: &HexCoord, rotation: i32) -> Vec<HexCoord> {
|
||||
let c = center.hex.xy();
|
||||
return self
|
||||
.footprint
|
||||
.iter()
|
||||
.map(|p| HexCoord::from_hex(*p + c).rotate_around(center, rotation))
|
||||
.collect();
|
||||
}
|
||||
|
||||
pub fn get_neighbors(&self, center: &HexCoord) -> Vec<HexCoord> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn get_neighbors_rotated(&self, center: &HexCoord, rotation: i32) -> Vec<HexCoord> {
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
pub mod buildings_database;
|
||||
pub mod assets;
|
||||
pub mod building_plugin;
|
||||
pub mod buildings_database;
|
||||
pub mod footprint;
|
||||
|
||||
pub use building_plugin::*;
|
||||
pub use building_plugin::*;
|
||||
|
||||
@@ -20,9 +20,11 @@ fn main() {
|
||||
primary_window: Some(Window {
|
||||
title: "Phos".into(),
|
||||
name: Some("phos".into()),
|
||||
#[cfg(debug_assertions)]
|
||||
resolution: (1920., 1080.).into(),
|
||||
present_mode: PresentMode::AutoNoVsync,
|
||||
// mode: bevy::window::WindowMode::BorderlessFullscreen,
|
||||
#[cfg(not(debug_assertions))]
|
||||
mode: bevy::window::WindowMode::BorderlessFullscreen,
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
|
||||
@@ -7,6 +7,7 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
bevy = "0.13.2"
|
||||
serde = {version="1.0.203", features=["derive"]}
|
||||
|
||||
|
||||
[features]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod despawn;
|
||||
pub mod resource;
|
||||
pub mod states;
|
||||
pub mod tags;
|
||||
|
||||
7
game/shared/src/resource.rs
Normal file
7
game/shared/src/resource.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct ResourceIdentifier {
|
||||
pub id: u32,
|
||||
pub qty: u32,
|
||||
}
|
||||
Reference in New Issue
Block a user