use crate::shared::player::*; use crate::shared::*; #[derive(Bundle)] pub struct ProjectileBundle { pub projectile: Projectile, pub replicate: Replicate, } impl ProjectileBundle { pub fn new(projectile: Projectile) -> Self { ProjectileBundle { projectile, replicate: Replicate { replication_group: ReplicationGroup::default().set_priority(1.), ..Default::default() }, } } } #[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, }