place core to start the game

This commit is contained in:
Jim 2025-09-01 21:54:50 -04:00
parent 3a25a1bd87
commit 1ecd054a31
Signed by: jim
GPG key ID: 3D7D94BA53088BF4
8 changed files with 67 additions and 24 deletions

View file

@ -13,6 +13,7 @@ resources = { path = "../resources" }
building = { path = "../building" }
input = { path = "../input" }
building_placement = { path = "../building_placement" }
building_core = { path = "../building_core" }
upgrade = { path = "../upgrade" }
combat = { path = "../combat" }

View file

@ -10,11 +10,12 @@ use bevy_egui::{
egui::{self, Align2, RichText},
};
use building::{BuildingInfo, Core};
use building_core::CorePreview;
use building_placement::SelectBuildingPreview;
use combat::Range;
use input::{SelectEntity, Selected};
use resources::{AvailableWorkers, Cost, ResourceDeposit, Resources, WorkedResourceDeposit};
use state::{BasePhaseState, Phase};
use state::{BasePhaseState, CoreState, Phase};
use ui_state::GameUIState;
use upgrade::{UnlockUpgrade, Upgradable, Upgrade};
@ -27,7 +28,10 @@ impl Plugin for UiIngamePlugin {
.add_systems(
EguiPrimaryContextPass,
(
side_panel.run_if(in_state(GameUIState::Default)),
place_core
.run_if(in_state(GameUIState::Default).and(in_state(CoreState::Unplaced))),
side_panel
.run_if(in_state(GameUIState::Default).and(in_state(CoreState::Placed))),
plan_ui.run_if(in_state(GameUIState::Default).and(in_state(Phase::Plan))),
execute_ui.run_if(in_state(GameUIState::Default).and(in_state(Phase::Execute))),
transition_ui.run_if(
@ -56,6 +60,7 @@ impl Plugin for UiIngamePlugin {
}
}
const VERY_LARGE_FONT_SIZE: f32 = 48.;
const LARGE_FONT_SIZE: f32 = 24.;
const FONT_SIZE: f32 = 16.;
@ -80,7 +85,7 @@ fn plan_ui(
.anchor(Align2::CENTER_BOTTOM, [0., 0.])
.show(ctx, |ui| {
if ui
.button(RichText::new("EXECUTE").size(LARGE_FONT_SIZE))
.button(RichText::new("EXECUTE").size(VERY_LARGE_FONT_SIZE))
.clicked()
{
next_phase.set(BasePhaseState::Execute {
@ -334,3 +339,21 @@ fn side_panel(
}
});
}
fn place_core(
mut contexts: EguiContexts,
mut selected_preview_writer: EventWriter<SelectBuildingPreview>,
core_preview: Single<Entity, With<CorePreview>>,
) {
let ctx = contexts.ctx_mut().unwrap();
egui::Window::new("PlaceCore")
.resizable(false)
.collapsible(false)
.title_bar(false)
.anchor(Align2::CENTER_BOTTOM, [0., 0.])
.show(ctx, |ui| {
if ui.button(RichText::new("COLONIZE").size(64.)).clicked() {
selected_preview_writer.write(SelectBuildingPreview(Some(*core_preview)));
}
});
}