cannon components and systems

This commit is contained in:
nquidox 2026-04-18 00:40:45 +03:00
parent 71f6b549b7
commit 30412844b8
5 changed files with 253 additions and 2 deletions

View file

@ -0,0 +1,46 @@
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;