use bevy::math::Vec2; use bevy::prelude::{Bundle, Component, Entity, Event, Resource, Transform}; use bevy_rapier2d::dynamics::AdditionalMassProperties; use bevy_rapier2d::dynamics::RigidBody; use bevy_rapier2d::geometry::Collider; use bevy_rapier2d::prelude::*; use serde::{Deserialize, Serialize}; #[derive(Component, Serialize, Deserialize)] pub struct Ball; #[derive(Component, Serialize, Deserialize)] pub struct Ground; #[derive(Component)] pub struct MainCamera; #[derive(Component)] pub struct StarfieldFront; #[derive(Component)] pub struct StarfieldMid; #[derive(Component)] pub struct StarfieldBack; #[derive(Resource, Default)] pub struct CursorWorldCoordinates(pub Option); #[derive(Debug, Default, Deserialize, Event, Serialize)] pub struct SendBallHere(pub Vec2); #[derive(Debug, Deserialize, Event, Serialize)] pub enum ThrustEvent { Up(bool), Down(bool), Left(bool), Right(bool), } #[derive(Component, Serialize, Deserialize, Debug)] #[require(ReadMassProperties, RigidBody::Dynamic, ExternalForce, ExternalImpulse)] pub struct Part { pub sprite: String, pub width: f32, pub height: f32, pub mass: f32, } #[derive(Bundle)] pub struct PartBundle { pub part: Part, pub transform: Transform, pub collider: Collider, pub additional_mass_properties: AdditionalMassProperties, } #[derive(Component, Serialize, Deserialize, Debug)] pub struct Player { pub client: Entity, } #[derive(Component, Default, Serialize, Deserialize, Debug)] #[allow(clippy::struct_excessive_bools, reason = "It's not a state machine")] pub struct PlayerThrust { pub up: bool, pub down: bool, pub left: bool, pub right: bool, }