use crate::protocol::*; use crate::shared::damage::*; use crate::shared::player::*; use bevy::prelude::*; use lightyear::prelude::*; use serde::*; #[derive(Bundle)] pub struct ProjectileBundle { pub projectile: Projectile, pub projectile_color: ProjectileColor, pub replicate: Replicate, } impl ProjectileBundle { pub fn new(projectile: Projectile, projectile_color: ProjectileColor) -> Self { ProjectileBundle { projectile, projectile_color: projectile_color, 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: Damage, } #[derive(Component, Message, Serialize, Deserialize, Clone, Debug, PartialEq)] pub struct ProjectileColor(pub Color); #[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, pub max_distance: f32, pub scale_damage: Option<(f32, f32)>, } #[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, }