Implement camera system
This commit is contained in:
@@ -8,7 +8,7 @@ use strum_macros::EnumIter;
|
||||
|
||||
use crate::{
|
||||
AppState,
|
||||
fighter::{FighterAttributes, animation::AnimKind},
|
||||
fighter::{FighterAttributes, FighterCameraProfile, animation::AnimKind},
|
||||
game_settings::GameSettings,
|
||||
};
|
||||
|
||||
@@ -22,6 +22,7 @@ pub struct FighterManifest {
|
||||
pub id: FighterId,
|
||||
pub model_path: String,
|
||||
pub attributes: FighterAttributes,
|
||||
pub camera: FighterCameraProfile,
|
||||
pub animations: HashMap<AnimKind, String>,
|
||||
}
|
||||
|
||||
@@ -93,6 +94,13 @@ pub fn prepare_fighter_manifests(
|
||||
);
|
||||
return;
|
||||
}
|
||||
if !manifest.camera.is_valid() {
|
||||
fail(
|
||||
&mut next_state,
|
||||
&format!("{:?} has an invalid camera profile", manifest.id),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if registry.insert(manifest.id, handle.clone()).is_some() {
|
||||
fail(
|
||||
&mut next_state,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
use bevy::prelude::*;
|
||||
use bevy_egui::EguiPrimaryContextPass;
|
||||
use bevy_ggrs::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub mod animation;
|
||||
pub mod attributes;
|
||||
@@ -48,6 +49,27 @@ pub enum FighterFacingDirection {
|
||||
Left,
|
||||
Right,
|
||||
}
|
||||
#[derive(Component, Copy, Clone, Debug, Reflect, Serialize, Deserialize)]
|
||||
#[reflect(opaque)]
|
||||
pub struct FighterCameraProfile {
|
||||
pub vertical_origin_offset: FGi32,
|
||||
pub forward_extent: FGi32,
|
||||
pub backward_extent: FGi32,
|
||||
pub upward_extent: FGi32,
|
||||
pub downward_extent: FGi32,
|
||||
/// Reserved for future offscreen indicators and close-up camera modes.
|
||||
pub visibility_radius: FGi32,
|
||||
}
|
||||
|
||||
impl FighterCameraProfile {
|
||||
pub fn is_valid(&self) -> bool {
|
||||
self.forward_extent >= FGi32::ZERO
|
||||
&& self.backward_extent >= FGi32::ZERO
|
||||
&& self.upward_extent >= FGi32::ZERO
|
||||
&& self.downward_extent >= FGi32::ZERO
|
||||
&& self.visibility_radius >= FGi32::ZERO
|
||||
}
|
||||
}
|
||||
|
||||
impl FighterFacingDirection {
|
||||
pub fn to_sign(&self) -> FGi32 {
|
||||
@@ -126,6 +148,7 @@ pub fn spawn_fighter(
|
||||
player_handle: usize,
|
||||
spawn_position: FGVec2,
|
||||
attributes: FighterAttributes,
|
||||
camera_profile: FighterCameraProfile,
|
||||
animations: FighterAnimations,
|
||||
visual_root: WorldAssetRoot,
|
||||
) {
|
||||
@@ -142,6 +165,7 @@ pub fn spawn_fighter(
|
||||
FighterVelocity::default(),
|
||||
FighterTranslation(spawn_position),
|
||||
attributes,
|
||||
camera_profile,
|
||||
visual_root,
|
||||
animations,
|
||||
FighterState::Fall(FallState),
|
||||
|
||||
Reference in New Issue
Block a user