misc
This commit is contained in:
@@ -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::*;
|
||||
|
||||
Reference in New Issue
Block a user