aboutsummaryrefslogtreecommitdiffstats
path: root/src/shared/projectile.rs
blob: f944e8abda724c74c2345928f2c88ad0755bbf45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::shared::*;

#[derive(Bundle)]
pub struct ProjectileBundle {
    pub projectile: Projectile,
    pub replicate: Replicate,
}

#[derive(Component, Message, Serialize, Deserialize, Clone, Debug, PartialEq)]

pub struct Projectile {
    pub type_: ProjectileType,
    pub source_player: PlayerId,
    pub damage: f32,
}

#[derive(Component, Message, Serialize, Deserialize, Clone, Debug, PartialEq)]
pub enum ProjectileType {
    Free(FreeProjectile),
    Instant(InstantProjectile),
    Targeted(TargetedProjectile),
}

#[derive(Component, Message, Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct FreeProjectile {
    pub position: Vec2,
    pub direction: Vec2,
    pub starting_position: Vec2,
}

#[derive(Component, Message, Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct InstantProjectile {
    pub target_player: PlayerId,
}

#[derive(Component, Message, Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct TargetedProjectile {
    pub target_player: PlayerId,
    pub position: Vec2,
}