pub mod thruster; use crate::config::part::PartConfig; use bevy::ecs::entity::MapEntities; use bevy::math::{Quat, Vec2}; use bevy::camera::visibility::RenderLayers; use crate::prelude::*; use bevy_replicon::prelude::Replicated; use serde::{Deserialize, Serialize}; use avian2d::prelude::*; use crate::thrust::ThrustSolution; use std::sync::LazyLock; #[derive(States, Debug, Clone, PartialEq, Eq, Hash)] pub enum GameplayState { Main, Starguide, } pub const MAIN_LAYER: RenderLayers = RenderLayers::layer(0); pub const STARGUIDE_LAYER: RenderLayers = RenderLayers::layer(1); pub static MAIN_STAR_LAYERS: LazyLock = LazyLock::new(|| RenderLayers::from_layers(&[0, 1])); #[derive(Component)] pub struct MainCamera; #[derive(Component)] pub struct StarguideCamera; #[derive(Component)] pub struct StarfieldFront; #[derive(Component)] pub struct StarfieldMid; #[derive(Component)] pub struct StarfieldBack; #[derive(Component)] pub struct FuelText; #[derive(Component)] pub struct PowerText; #[derive(Component, Serialize, Deserialize, Debug)] #[require( RigidBody::Dynamic, LinearVelocity, AngularVelocity, ConstantForce, Replicated, )] pub struct Part { pub strong_config: PartConfig, } #[derive(Component, Debug)] #[require(Replicated)] pub struct PartHandle(pub Handle); #[derive(Component, Serialize, Deserialize, Debug)] #[require(Replicated)] pub struct Player { #[entities] pub client: Entity, } #[derive(Component, Serialize, Deserialize, Debug)] #[require(Replicated)] pub struct Particles { pub effect: String, pub active: bool, } #[derive(Serialize, Deserialize, Message, Debug, MapEntities, Clone)] pub struct DragRequestEvent { #[entities] pub drag_target: Entity, pub drag_to: Vec2, pub set_rotation: Quat, #[entities] pub snap_target: Option, #[entities] pub peer_snap: Option, } #[derive(Component, Serialize, Deserialize, Debug)] #[require(Replicated)] pub struct PlayerStorage { pub fuel_capacity: f32, pub fuel: f32, pub power_capacity: f32, pub power: f32, } #[derive(Component)] pub struct Me; #[derive(Component)] pub struct StarguideMe; #[derive(Message, Serialize, Deserialize, Debug, MapEntities)] pub struct Hi { #[entities] pub you_are: Entity }