All engine plugin registrations now live in CoreGamePlugin::build(). build_app() is reduced to DefaultPlugins setup + CoreGamePlugin registration. sync_provider is threaded through CoreGamePlugin::new() via Mutex<Option<...>>. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,15 +1,101 @@
|
||||
//! Central plugin that groups all gameplay systems.
|
||||
//! Central plugin that groups all gameplay plugins.
|
||||
//!
|
||||
//! Register [`CoreGamePlugin`] once in the app instead of the individual
|
||||
//! plugins. Systems are added here rather than directly in the app entry point.
|
||||
//! plugins. Plugin registration lives here rather than directly in the app
|
||||
//! entry point.
|
||||
|
||||
use std::sync::Mutex;
|
||||
|
||||
use bevy::prelude::*;
|
||||
|
||||
/// Groups all Ferrous Solitaire gameplay plugins.
|
||||
pub struct CoreGamePlugin;
|
||||
use crate::{
|
||||
AchievementPlugin, AnalyticsPlugin, AnimationPlugin, AssetSourcesPlugin, AudioPlugin,
|
||||
AutoCompletePlugin, AvatarPlugin, CardAnimationPlugin, CardPlugin, ChallengePlugin,
|
||||
CursorPlugin, DailyChallengePlugin, DiagnosticsHudPlugin, DifficultyPlugin, FeedbackAnimPlugin,
|
||||
FontPlugin, GamePlugin, HelpPlugin, HomePlugin, HudPlugin, InputPlugin, LeaderboardPlugin,
|
||||
OnboardingPlugin, PausePlugin, PlayBySeedPlugin, ProfilePlugin, ProgressPlugin,
|
||||
RadialMenuPlugin, ReplayOverlayPlugin, ReplayPlaybackPlugin, SafeAreaInsetsPlugin,
|
||||
SelectionPlugin, SettingsPlugin, SplashPlugin, StatsPlugin, SyncPlugin, SyncProvider,
|
||||
SyncSetupPlugin, TablePlugin, ThemePlugin, ThemeRegistryPlugin, TimeAttackPlugin,
|
||||
UiFocusPlugin, UiModalPlugin, UiTooltipPlugin, WeeklyGoalsPlugin, WinSummaryPlugin,
|
||||
};
|
||||
|
||||
impl Plugin for CoreGamePlugin {
|
||||
fn build(&self, _app: &mut App) {
|
||||
// Gameplay systems will be migrated here in follow-up issues.
|
||||
/// Groups all Ferrous Solitaire gameplay plugins.
|
||||
pub struct CoreGamePlugin {
|
||||
sync_provider: Mutex<Option<Box<dyn SyncProvider + Send + Sync>>>,
|
||||
}
|
||||
|
||||
impl CoreGamePlugin {
|
||||
/// Create a new [`CoreGamePlugin`] with the sync provider used by [`SyncPlugin`].
|
||||
pub fn new(sync_provider: Box<dyn SyncProvider + Send + Sync>) -> Self {
|
||||
Self {
|
||||
sync_provider: Mutex::new(Some(sync_provider)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Plugin for CoreGamePlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
let mut sync_provider = match self.sync_provider.lock() {
|
||||
Ok(guard) => guard,
|
||||
Err(poisoned) => poisoned.into_inner(),
|
||||
};
|
||||
let sync_provider = sync_provider
|
||||
.take()
|
||||
.expect("CoreGamePlugin::build called twice");
|
||||
|
||||
app.add_plugins(AssetSourcesPlugin)
|
||||
.add_plugins(ThemePlugin)
|
||||
.add_plugins(ThemeRegistryPlugin)
|
||||
.add_plugins(FontPlugin)
|
||||
.add_plugins(GamePlugin)
|
||||
.add_plugins(TablePlugin)
|
||||
.add_plugins(CardPlugin)
|
||||
// Cursor-icon feedback is desktop-only; Android has no pointer cursor.
|
||||
// The drop-target highlight systems (update_drop_highlights,
|
||||
// update_drop_target_overlays) live in CursorPlugin but ARE useful
|
||||
// on Android — they've been left running because their Bevy system
|
||||
// params compile and function on Android; only the CursorIcon insert
|
||||
// is inert. Gate the whole plugin if the cursor APIs ever cause
|
||||
// Android linker issues; for now it's harmless to leave it registered.
|
||||
.add_plugins(CursorPlugin)
|
||||
.add_plugins(InputPlugin)
|
||||
.add_plugins(RadialMenuPlugin)
|
||||
.add_plugins(SelectionPlugin)
|
||||
.add_plugins(AnimationPlugin)
|
||||
.add_plugins(FeedbackAnimPlugin)
|
||||
.add_plugins(CardAnimationPlugin)
|
||||
.add_plugins(AutoCompletePlugin)
|
||||
.add_plugins(ReplayPlaybackPlugin)
|
||||
.add_plugins(ReplayOverlayPlugin)
|
||||
.add_plugins(StatsPlugin::default())
|
||||
.add_plugins(ProgressPlugin::default())
|
||||
.add_plugins(AchievementPlugin::default())
|
||||
.add_plugins(DailyChallengePlugin)
|
||||
.add_plugins(WeeklyGoalsPlugin)
|
||||
.add_plugins(ChallengePlugin)
|
||||
.add_plugins(PlayBySeedPlugin)
|
||||
.add_plugins(DifficultyPlugin)
|
||||
.add_plugins(TimeAttackPlugin)
|
||||
.add_plugins(SafeAreaInsetsPlugin)
|
||||
.add_plugins(HudPlugin)
|
||||
.add_plugins(HelpPlugin)
|
||||
.add_plugins(HomePlugin::default())
|
||||
.add_plugins(AvatarPlugin)
|
||||
.add_plugins(ProfilePlugin)
|
||||
.add_plugins(PausePlugin)
|
||||
.add_plugins(SettingsPlugin::default())
|
||||
.add_plugins(AudioPlugin)
|
||||
.add_plugins(OnboardingPlugin)
|
||||
.add_plugins(SyncPlugin::new(sync_provider))
|
||||
.add_plugins(SyncSetupPlugin)
|
||||
.add_plugins(AnalyticsPlugin)
|
||||
.add_plugins(LeaderboardPlugin)
|
||||
.add_plugins(WinSummaryPlugin)
|
||||
.add_plugins(UiModalPlugin)
|
||||
.add_plugins(UiFocusPlugin)
|
||||
.add_plugins(UiTooltipPlugin)
|
||||
.add_plugins(SplashPlugin)
|
||||
.add_plugins(DiagnosticsHudPlugin);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user