use crate::protocol::*; use crate::shared::activation::*; use crate::shared::buffs::*; use crate::shared::champion::*; use crate::shared::cooldown::*; use crate::shared::faction::*; use crate::shared::health::*; use crate::shared::imperative::*; use crate::shared::name::*; use crate::shared::shape::*; use crate::shared::stats::*; use bevy::prelude::*; use lightyear::prelude::*; use serde::*; #[derive(Bundle)] pub struct PlayerBundle { id: PlayerId, position: PlayerPosition, color: PlayerColor, imperative: Imperative, cooldown: Cooldown, health: Health, champion: Champion, effective_stats: EffectiveStats, buffs: Buffs, activation: Activation, shape: Shape, faction: Faction, player: Player, name: Name_, replicate: Replicate, } impl PlayerBundle { pub fn new(id: ClientId, name: String, position: Vec2, color: Color) -> Self { let mut replicate = Replicate { replication_group: ReplicationGroup::default().set_priority(10.), ..Default::default() }; replicate.enable_replicate_once::(); replicate.enable_replicate_once::(); replicate.target::(NetworkTarget::Single(id)); replicate.target::(NetworkTarget::Single(id)); replicate.target::(NetworkTarget::Single(id)); let champion = Champion::default(); let effective_stats = EffectiveStats(champion.base_stats().0); PlayerBundle { id: PlayerId(id), position: PlayerPosition(position), color: PlayerColor(color), imperative: Imperative::Idle, cooldown: Cooldown::default(), health: Health { health: effective_stats.0.max_health, shield: 0., }, champion, effective_stats, buffs: Buffs::default(), activation: Activation::default(), shape: Shape::player(), faction: Faction::default(), player: Player::default(), name: Name_(name), replicate, } } } #[derive(Component, Message, Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)] pub struct PlayerId(pub ClientId); #[derive(Component, Message, Serialize, Deserialize, Clone, Copy, Debug, PartialEq)] pub struct PlayerPosition(pub Vec2); #[derive(Component, Message, Serialize, Deserialize, Clone, Debug, PartialEq)] pub struct PlayerColor(pub Color); #[derive(Component, Message, Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Default)] pub struct Player;