This commit is contained in:
2024-06-10 21:28:04 -04:00
parent 05f9fa3143
commit 8cecad83c2
12 changed files with 76 additions and 9 deletions

View File

@@ -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 = []

View 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>,
}

View File

@@ -0,0 +1 @@
pub mod building_asset;

View 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!();
}
}

View File

@@ -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::*;

View File

@@ -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()

View File

@@ -7,6 +7,7 @@ edition = "2021"
[dependencies]
bevy = "0.13.2"
serde = {version="1.0.203", features=["derive"]}
[features]

View File

@@ -1,3 +1,4 @@
pub mod despawn;
pub mod resource;
pub mod states;
pub mod tags;

View File

@@ -0,0 +1,7 @@
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct ResourceIdentifier {
pub id: u32,
pub qty: u32,
}