cannon components and systems
This commit is contained in:
parent
71f6b549b7
commit
30412844b8
5 changed files with 253 additions and 2 deletions
46
src/states/linear/components_cannon.rs
Normal file
46
src/states/linear/components_cannon.rs
Normal 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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue