update project
Some checks failed
CI / Tests (push) Failing after 1m33s
CI / Clippy lints (push) Failing after 1m40s
CI / Bevy lints (push) Failing after 2m14s

This commit is contained in:
2026-03-01 16:23:42 -05:00
parent 634fd5430c
commit 0e8a071a36
8 changed files with 172 additions and 100 deletions

View File

@@ -7,8 +7,10 @@ use crate::{components::camera::*, states::play::PlaySystems};
pub struct CameraPlugin;
impl Plugin for CameraPlugin {
fn build(&self, app: &mut App) {
impl Plugin for CameraPlugin
{
fn build(&self, app: &mut App)
{
app.add_systems(Update, camera_pitch.in_set(PlaySystems));
app.add_systems(
PostUpdate,
@@ -23,12 +25,16 @@ impl Plugin for CameraPlugin {
pub fn camera_attachment(
attachment_targets: Query<&GlobalTransform>,
cam: Single<(&mut Transform, &CameraAttachment, &CameraMode)>,
) {
)
{
let (mut transform, attach, mode) = cam.into_inner();
if let Ok(tgt) = attachment_targets.get(attach.0) {
match mode {
CameraMode::Player => {
if let Ok(tgt) = attachment_targets.get(attach.0)
{
match mode
{
CameraMode::Player =>
{
transform.rotation = tgt.rotation();
transform.translation = tgt.translation();
}
@@ -38,8 +44,10 @@ pub fn camera_attachment(
}
}
pub fn camera_pitch(cam_query: Query<(&mut Transform, &CameraPitch)>) {
for (mut cam_transform, pitch) in cam_query {
pub fn camera_pitch(cam_query: Query<(&mut Transform, &CameraPitch)>)
{
for (mut cam_transform, pitch) in cam_query
{
cam_transform.rotation = Quat::from_rotation_x(pitch.0);
}
}
@@ -47,20 +55,25 @@ pub fn camera_pitch(cam_query: Query<(&mut Transform, &CameraPitch)>) {
#[cfg(feature = "dev")]
pub fn camera_toggle(
key: Res<ButtonInput<KeyCode>>,
mut window: Single<&mut Window, With<PrimaryWindow>>,
mut cursor_options: Single<&mut CursorOptions, With<PrimaryWindow>>,
camera: Single<&mut CameraMode>,
) {
)
{
use bevy::window::CursorGrabMode;
let mut mode = camera.into_inner();
if key.just_pressed(KeyCode::Escape) {
if window.cursor_options.visible {
if key.just_pressed(KeyCode::Escape)
{
if cursor_options.visible
{
*mode = CameraMode::Player;
window.cursor_options.grab_mode = CursorGrabMode::Locked;
window.cursor_options.visible = false;
} else {
cursor_options.grab_mode = CursorGrabMode::Locked;
cursor_options.visible = false;
}
else
{
*mode = CameraMode::Disabled;
window.cursor_options.grab_mode = CursorGrabMode::None;
window.cursor_options.visible = true;
cursor_options.grab_mode = CursorGrabMode::None;
cursor_options.visible = true;
}
}
}