place core to start the game
This commit is contained in:
parent
3a25a1bd87
commit
1ecd054a31
8 changed files with 67 additions and 24 deletions
|
|
@ -13,6 +13,7 @@ impl Plugin for StatePlugin {
|
|||
.enable_state_scoped_entities::<AppState>()
|
||||
.add_sub_state::<GameState>()
|
||||
.add_sub_state::<BasePhaseState>()
|
||||
.add_sub_state::<CoreState>()
|
||||
.enable_state_scoped_entities::<GameState>()
|
||||
.add_computed_state::<Phase>()
|
||||
.configure_sets(
|
||||
|
|
@ -112,17 +113,31 @@ pub enum Phase {
|
|||
}
|
||||
|
||||
impl ComputedStates for Phase {
|
||||
type SourceStates = (BasePhaseState, GameState);
|
||||
type SourceStates = (BasePhaseState, GameState, CoreState);
|
||||
|
||||
fn compute(sources: Self::SourceStates) -> Option<Self> {
|
||||
match sources {
|
||||
(_, GameState::Loading) | (_, GameState::Paused) => None,
|
||||
(BasePhaseState::Execute { .. }, GameState::Running) => Some(Self::Execute),
|
||||
(BasePhaseState::Plan { .. }, GameState::Running) => Some(Self::Plan),
|
||||
(_, GameState::Loading, _) | (_, GameState::Paused, _) => None,
|
||||
(_, _, CoreState::Dead) | (_, _, CoreState::Unplaced) => None,
|
||||
(BasePhaseState::Execute { .. }, GameState::Running, CoreState::Placed) => {
|
||||
Some(Self::Execute)
|
||||
}
|
||||
(BasePhaseState::Plan { .. }, GameState::Running, CoreState::Placed) => {
|
||||
Some(Self::Plan)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, Eq, PartialEq, Hash, SubStates)]
|
||||
#[source(AppState = AppState::Game)]
|
||||
pub enum CoreState {
|
||||
#[default]
|
||||
Unplaced,
|
||||
Placed,
|
||||
Dead,
|
||||
}
|
||||
|
||||
#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]
|
||||
pub enum GameSystemSet {
|
||||
// fixed update - contains all gameplay logic. does not run when game is paused
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue