use crate::states::linear::RoundBallType; use bevy::prelude::*; use std::mem; #[derive(Component)] pub struct LinearCannon; #[derive(Resource, Debug, Clone)] pub struct LinearCannonState { pub shot: RoundBallType, pub swap: RoundBallType, } impl Default for LinearCannonState { fn default() -> Self { Self { shot: RoundBallType::random_from_4(), swap: RoundBallType::random_from_4(), } } } impl LinearCannonState { pub fn fire(&mut self) { self.shot = self.swap; self.swap = RoundBallType::random_from_4(); } pub fn cycle(&mut self) { mem::swap(&mut self.shot, &mut self.swap); } } #[derive(Component)] pub struct RoundBallProjectile { pub velocity: Vec2, pub previous_position: Vec2, pub ball_type: RoundBallType, } #[derive(Component)] pub struct ShotMarker; #[derive(Component)] pub struct SwapMarker;