zuma-like/src/states/linear/components_cannon.rs

46 lines
921 B
Rust
Raw Normal View History

2026-04-18 00:40:45 +03:00
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;