From 98c2ba59dfcf4afecde7a95a08bfb18481e0af7b Mon Sep 17 00:00:00 2001 From: francy51 Date: Mon, 15 Jun 2026 20:02:19 -0400 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(gameplay):=20implement=20in-sy?= =?UTF-8?q?stem=20gameplay=20with=20camera=20modes=20and=20flight=20contro?= =?UTF-8?q?ls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add comprehensive in-system gameplay features including: Camera System: - Orbit mode for galaxy/inspection views - Follow mode for tracking player ship during flight - Cinematic mode for docked/cutscene views - Smooth interpolation and orbit controls In-System Gameplay: - Docked state at stations with undock functionality - Flight mode with velocity and target-based navigation - Point-and-click movement via ground plane projection - Target selection system for POIs Flight Controls: - Flight state tracking with speed monitoring - Automatic camera transitions between modes - Flight HUD with speed indicator and status panel - Contextual action system for approach/dock/mining UI Updates: - Docked station panel with system information - Flight mode controls and hints - Dynamic population display This implementation provides the foundation for tactical space gameplay with smooth camera transitions and intuitive point-and-click navigation. Co-Authored-By: Claude Opus 4.8 --- apps/game/src/camera.rs | 155 ++++++++ apps/game/src/gameplay/galaxy/contents.rs | 19 +- apps/game/src/gameplay/galaxy/mod.rs | 2 +- apps/game/src/gameplay/galaxy/poi.rs | 8 +- apps/game/src/gameplay/in_system/actions.rs | 332 ++++++++++++++++++ apps/game/src/gameplay/in_system/flight.rs | 174 +++++++++ apps/game/src/gameplay/in_system/flight_ui.rs | 170 +++++++++ apps/game/src/gameplay/in_system/mod.rs | 89 ++++- .../game/src/gameplay/in_system/operations.rs | 176 ++++++++++ apps/game/src/gameplay/in_system/scene.rs | 84 +++-- apps/game/src/gameplay/in_system/target.rs | 119 +++++++ apps/game/src/gameplay/in_system/ui.rs | 12 +- apps/game/src/gameplay/movement/input.rs | 9 + apps/game/src/main.rs | 32 +- 14 files changed, 1338 insertions(+), 43 deletions(-) create mode 100644 apps/game/src/gameplay/in_system/actions.rs create mode 100644 apps/game/src/gameplay/in_system/flight.rs create mode 100644 apps/game/src/gameplay/in_system/flight_ui.rs create mode 100644 apps/game/src/gameplay/in_system/operations.rs create mode 100644 apps/game/src/gameplay/in_system/target.rs diff --git a/apps/game/src/camera.rs b/apps/game/src/camera.rs index 835d217..23845d2 100644 --- a/apps/game/src/camera.rs +++ b/apps/game/src/camera.rs @@ -7,6 +7,53 @@ use crate::ui::util::cursor_over_ui; #[derive(Component)] pub struct MainCamera; +/// Camera mode determines how the camera behaves. +/// - Orbit: Free-look inspection around a target (Galaxy view, docked inspection) +/// - Follow: Tracks behind a moving entity (player ship during flight) +/// - Cinematic: Fixed cinematic shot (docked view, cutscenes) +#[derive(Debug, Clone, Copy, PartialEq, Default)] +pub enum CameraMode { + #[default] + Orbit, + Follow, + Cinematic, +} + +impl CameraMode { + pub fn is_orbit(&self) -> bool { + matches!(self, Self::Orbit) + } + + pub fn is_follow(&self) -> bool { + matches!(self, Self::Follow) + } + + pub fn is_cinematic(&self) -> bool { + matches!(self, Self::Cinematic) + } +} + +/// Global camera state resource. Controls which camera mode is active +/// and which entity the camera should follow (if any). +#[derive(Resource, Default, Debug)] +pub struct CameraState { + pub mode: CameraMode, + pub target_entity: Option, + pub follow_distance: f32, + pub follow_height: f32, +} + +/// Follow camera component. Attached to the MainCamera when in Follow mode, +/// this configures how the camera tracks its target. +#[derive(Component, Debug, Clone)] +pub struct FollowCamera { + pub target: Entity, + pub distance: f32, + pub height: f32, + pub stiffness: f32, + pub damping: f32, +} + /// Orbit-style camera: rotates around `target` at `distance`, controlled by mouse. /// Used for inspection scenes like Galaxy where there is no player to follow. /// @@ -73,7 +120,10 @@ const ORBIT_MAX_DISTANCE: f32 = 1500.0; /// /// Drag is suppressed when the cursor is over any UI node — otherwise clicking /// buttons or panels would also rotate the camera. +/// +/// Only runs when camera mode is Orbit. pub fn orbit_camera_control( + camera_state: Res, mouse_input: Res>, primary_window: Query<&Window, With>, mut mouse_motion: EventReader, @@ -81,6 +131,12 @@ pub fn orbit_camera_control( mut query: Query<(&mut Transform, &mut OrbitCamera), With>, ui_nodes: Query<(&bevy::ui::ComputedNode, &GlobalTransform)>, ) { + // Only run orbit controls in Orbit mode + if camera_state.mode != CameraMode::Orbit { + mouse_motion.clear(); + scroll_events.clear(); + return; + } let Ok((mut transform, mut orbit)) = query.single_mut() else { // Drain pending input to avoid stale buildup when there's no camera. mouse_motion.clear(); @@ -162,3 +218,102 @@ pub fn apply_orbit_reset( orbit.reset(); commands.remove_resource::(); } + +/// Follow camera system. Tracks behind the target entity (player ship) during flight. +/// The camera maintains a fixed distance and height behind the target, smoothly +/// interpolating to the ideal position each frame. +pub fn follow_camera_system( + time: Res