preparation of building asset structure
This commit is contained in:
@@ -3,7 +3,13 @@ use bevy::prelude::*;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use shared::identifiers::ResourceIdentifier;
|
use shared::identifiers::ResourceIdentifier;
|
||||||
|
|
||||||
use crate::footprint::BuildingFootprint;
|
use crate::{
|
||||||
|
buildings::{
|
||||||
|
basic_building::BasicBuildingInfo, factory_building::FactoryBuildingInfo,
|
||||||
|
resource_gathering::ResourceGatheringBuildingInfo,
|
||||||
|
},
|
||||||
|
footprint::BuildingFootprint,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Asset, TypePath, Debug, Serialize, Deserialize)]
|
#[derive(Asset, TypePath, Debug, Serialize, Deserialize)]
|
||||||
pub struct BuildingAsset {
|
pub struct BuildingAsset {
|
||||||
@@ -17,8 +23,25 @@ pub struct BuildingAsset {
|
|||||||
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 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!(
|
create_asset_loader!(
|
||||||
BuildingAssetPlugin,
|
BuildingAssetPlugin,
|
||||||
BuildingAssetLoader,
|
BuildingAssetLoader,
|
||||||
|
|||||||
4
game/buildings/src/buildings/basic_building.rs
Normal file
4
game/buildings/src/buildings/basic_building.rs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use shared::identifiers::ResourceIdentifier;
|
||||||
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
pub struct BasicBuildingInfo {}
|
||||||
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<()>
|
||||||
|
}
|
||||||
4
game/buildings/src/buildings/mod.rs
Normal file
4
game/buildings/src/buildings/mod.rs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
pub mod resource_gathering;
|
||||||
|
pub mod basic_building;
|
||||||
|
pub mod factory_building;
|
||||||
|
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::*;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use bevy::core_pipeline::experimental::taa::{TemporalAntiAliasBundle, TemporalAn
|
|||||||
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::*;
|
||||||
|
use bevy::render::view::RenderLayers;
|
||||||
use bevy::window::{CursorGrabMode, PrimaryWindow};
|
use bevy::window::{CursorGrabMode, PrimaryWindow};
|
||||||
use bevy_lunex::prelude::MainUi;
|
use bevy_lunex::prelude::MainUi;
|
||||||
use shared::sets::GameplaySet;
|
use shared::sets::GameplaySet;
|
||||||
@@ -62,7 +63,8 @@ fn setup(mut commands: Commands, mut msaa: ResMut<Msaa>) {
|
|||||||
PhosOrbitCamera::default(),
|
PhosOrbitCamera::default(),
|
||||||
MainUi,
|
MainUi,
|
||||||
))
|
))
|
||||||
.insert(TemporalAntiAliasBundle::default());
|
.insert(TemporalAntiAliasBundle::default())
|
||||||
|
.insert(RenderLayers::layer(0));
|
||||||
|
|
||||||
*msaa = Msaa::Off;
|
*msaa = Msaa::Off;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::{prelude::*, render::view::RenderLayers};
|
||||||
use bevy_lunex::prelude::*;
|
use bevy_lunex::prelude::*;
|
||||||
use shared::tags::MainCamera;
|
use shared::tags::MainCamera;
|
||||||
|
|
||||||
@@ -6,16 +6,23 @@ pub struct BuildUiPlugin;
|
|||||||
|
|
||||||
impl Plugin for BuildUiPlugin {
|
impl Plugin for BuildUiPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_plugins(UiDefaultPlugins)
|
// app.add_plugins(UiDefaultPlugins)
|
||||||
.add_plugins(UiDebugPlugin::<MainUi>::new());
|
// .add_plugins(UiDebugPlugin::<MainUi>::new());
|
||||||
|
|
||||||
app.add_systems(PostStartup, setup_ui);
|
app.add_systems(PostStartup, setup_ui);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_ui(mut commands: Commands, cam: Query<Entity, With<MainCamera>>, assets: Res<AssetServer>) {
|
fn setup_ui(mut commands: Commands, assets: Res<AssetServer>) {
|
||||||
let c = cam.single();
|
commands
|
||||||
commands.entity(c).insert(MainUi);
|
.spawn((
|
||||||
|
Camera2dBundle {
|
||||||
|
transform: Transform::from_xyz(0.0, 0.0, 1000.0),
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
MainUi,
|
||||||
|
))
|
||||||
|
.insert(RenderLayers::layer(1));
|
||||||
|
|
||||||
commands
|
commands
|
||||||
.spawn((
|
.spawn((
|
||||||
@@ -25,6 +32,7 @@ fn setup_ui(mut commands: Commands, cam: Query<Entity, With<MainCamera>>, assets
|
|||||||
},
|
},
|
||||||
Name::new("Build UI"),
|
Name::new("Build UI"),
|
||||||
SourceFromCamera,
|
SourceFromCamera,
|
||||||
|
RenderLayers::layer(1),
|
||||||
))
|
))
|
||||||
.with_children(|ui| {
|
.with_children(|ui| {
|
||||||
ui.spawn((
|
ui.spawn((
|
||||||
@@ -33,12 +41,14 @@ fn setup_ui(mut commands: Commands, cam: Query<Entity, With<MainCamera>>, assets
|
|||||||
.pos1(Ab(20.0))
|
.pos1(Ab(20.0))
|
||||||
.pos2(Rl(100.0) - Ab(20.0))
|
.pos2(Rl(100.0) - Ab(20.0))
|
||||||
.pack::<Base>(),
|
.pack::<Base>(),
|
||||||
|
RenderLayers::layer(1),
|
||||||
));
|
));
|
||||||
|
|
||||||
ui.spawn((
|
ui.spawn((
|
||||||
UiLink::<MainUi>::path("Root/Rect"),
|
UiLink::<MainUi>::path("Root/Rect"),
|
||||||
UiLayout::solid().size((Ab(1920.0), Ab(1080.0))).pack::<Base>(),
|
UiLayout::solid().size((Ab(1920.0), Ab(1080.0))).pack::<Base>(),
|
||||||
UiImage2dBundle::from(assets.load("textures/world/test2.png")),
|
UiImage2dBundle::from(assets.load("textures/world/test2.png")),
|
||||||
|
RenderLayers::layer(1),
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -17,3 +18,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),
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use bevy::reflect::Reflect;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub mod assets;
|
pub mod assets;
|
||||||
pub mod components;
|
pub mod components;
|
||||||
|
|||||||
Reference in New Issue
Block a user