buildings wip
This commit is contained in:
@@ -12,7 +12,7 @@ pub struct BuildingAsset {
|
||||
pub footprint: BuildingFootprint,
|
||||
pub prefab_path: String,
|
||||
#[serde(skip)]
|
||||
pub prefab: Handle<()>,
|
||||
pub prefab: Handle<Scene>,
|
||||
|
||||
pub cost: Vec<ResourceIdentifier>,
|
||||
pub consumption: Vec<ResourceIdentifier>,
|
||||
|
||||
@@ -5,7 +5,9 @@ use serde::{Deserialize, Serialize};
|
||||
use super::building_asset::BuildingAsset;
|
||||
|
||||
#[derive(Resource)]
|
||||
pub struct BuildingDatabase(Handle<BuildingDatabaseAsset>);
|
||||
pub struct BuildingDatabase{
|
||||
pub handle: Handle<BuildingDatabaseAsset>
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, TypePath, Asset)]
|
||||
pub struct BuildingDatabaseAsset {
|
||||
|
||||
@@ -1,18 +1,29 @@
|
||||
use bevy::{prelude::*, window::PrimaryWindow};
|
||||
use bevy_rapier3d::{pipeline::QueryFilter, plugin::RapierContext};
|
||||
use shared::{despawn::Despawn, states::GameplayState, tags::MainCamera};
|
||||
use shared::{
|
||||
despawn::Despawn,
|
||||
states::{AssetLoadState, GameplayState},
|
||||
tags::MainCamera,
|
||||
};
|
||||
use world_generation::{hex_utils::HexCoord, map::map::Map};
|
||||
|
||||
use crate::build_queue::{BuildQueue, QueueEntry};
|
||||
use crate::{
|
||||
assets::{
|
||||
building_asset::BuildingAssetPlugin,
|
||||
building_database::{BuildingDatabase, BuildingDatabasePlugin},
|
||||
},
|
||||
build_queue::{BuildQueue, QueueEntry},
|
||||
};
|
||||
|
||||
pub struct BuildingPugin;
|
||||
|
||||
impl Plugin for BuildingPugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.insert_resource(BuildQueue::default());
|
||||
app.add_plugins(BuildingAssetPlugin).add_plugins(BuildingDatabasePlugin);
|
||||
|
||||
app.add_systems(Startup, init);
|
||||
//app.add_systems(Update, hq_placement.run_if(in_state(GameplayState::PlaceHQ)));
|
||||
app.add_systems(Startup, init.run_if(in_state(AssetLoadState::StartLoading)));
|
||||
app.add_systems(Update, hq_placement.run_if(in_state(GameplayState::PlaceHQ)));
|
||||
|
||||
app.add_systems(PreUpdate, process_build_queue.run_if(in_state(GameplayState::Playing)));
|
||||
}
|
||||
@@ -21,11 +32,19 @@ impl Plugin for BuildingPugin {
|
||||
#[derive(Resource)]
|
||||
struct IndicatorCube(Handle<Mesh>, Handle<StandardMaterial>);
|
||||
|
||||
fn init(mut commands: Commands, mut meshes: ResMut<Assets<Mesh>>, mut materials: ResMut<Assets<StandardMaterial>>) {
|
||||
fn init(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
asset_server: Res<AssetServer>,
|
||||
) {
|
||||
let cube = Cuboid::from_size(Vec3::splat(1.));
|
||||
let mesh_handle = meshes.add(cube);
|
||||
let mat_handle = materials.add(Color::WHITE);
|
||||
commands.insert_resource(IndicatorCube(mesh_handle, mat_handle));
|
||||
|
||||
let db = asset_server.load("buildings/buildings.db.json");
|
||||
commands.insert_resource(BuildingDatabase { handle: db });
|
||||
}
|
||||
|
||||
fn hq_placement(
|
||||
|
||||
Submodule game/main/assets updated: d7389cf5b1...59a833a575
@@ -1,15 +1,15 @@
|
||||
#[cfg(feature = "tracing")]
|
||||
use bevy::log::*;
|
||||
use bevy::{
|
||||
asset::{AssetEvents, LoadState},
|
||||
asset::LoadState,
|
||||
pbr::{ExtendedMaterial, NotShadowCaster},
|
||||
prelude::*,
|
||||
};
|
||||
use bevy_inspector_egui::quick::ResourceInspectorPlugin;
|
||||
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
|
||||
use shared::states::{GameplayState, MenuState};
|
||||
use shared::states::{AssetLoadState, GameplayState, MenuState};
|
||||
use world_generation::{
|
||||
biome_asset::{BiomeAsset, BiomeAssetLoadState},
|
||||
biome_asset::{BiomeAsset, BiomeAssetLoadState, BiomeAssetPlugin},
|
||||
biome_painter::*,
|
||||
heightmap::generate_heightmap,
|
||||
hex_utils::{offset_to_index, SHORT_DIAGONAL},
|
||||
@@ -42,6 +42,12 @@ impl Plugin for MapInitPlugin {
|
||||
app.insert_state(GeneratorState::Startup);
|
||||
app.insert_state(AssetLoadState::StartLoading);
|
||||
|
||||
//Assets
|
||||
app.add_plugins(TileAssetPlugin);
|
||||
app.add_plugins(TileMapperAssetPlugin);
|
||||
app.add_plugins(BiomePainterPlugin);
|
||||
app.add_plugins(BiomeAssetPlugin);
|
||||
|
||||
app.add_plugins(ResourceInspectorPlugin::<GenerationConfig>::default());
|
||||
app.add_plugins(ResourceInspectorPlugin::<WaterInspect>::default());
|
||||
app.register_type::<ExtendedMaterial<StandardMaterial, WaterMaterial>>();
|
||||
|
||||
@@ -13,9 +13,6 @@ use buildings::BuildingPugin;
|
||||
use iyes_perf_ui::prelude::*;
|
||||
use shared::despawn::DespawnPuglin;
|
||||
use shared::states::{GameplayState, MenuState};
|
||||
use world_generation::tile_manager::TileAssetPlugin;
|
||||
use world_generation::tile_mapper::TileMapperAssetPlugin;
|
||||
use world_generation::{biome_asset::BiomeAssetPlugin, biome_painter::BiomePainterPlugin};
|
||||
|
||||
pub struct PhosGamePlugin;
|
||||
|
||||
@@ -44,11 +41,6 @@ impl Plugin for PhosGamePlugin {
|
||||
.add_plugins(bevy::diagnostic::SystemInformationDiagnosticsPlugin)
|
||||
.add_plugins(PerfUiPlugin);
|
||||
|
||||
//Assets
|
||||
app.add_plugins(TileAssetPlugin);
|
||||
app.add_plugins(TileMapperAssetPlugin);
|
||||
app.add_plugins(BiomePainterPlugin);
|
||||
app.add_plugins(BiomeAssetPlugin);
|
||||
//Physics
|
||||
app.add_plugins(RapierPhysicsPlugin::<NoUserData>::default());
|
||||
// app.add_plugins(RapierDebugRenderPlugin::default());
|
||||
|
||||
@@ -15,3 +15,11 @@ pub enum GameplayState {
|
||||
PlaceHQ,
|
||||
Playing,
|
||||
}
|
||||
|
||||
#[derive(States, Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum AssetLoadState {
|
||||
StartLoading,
|
||||
Loading,
|
||||
FinalizeAssets,
|
||||
LoadComplete,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user