From 601474aa84cfc071c724051ac121e3c9cc796577 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Sun, 17 Mar 2024 09:26:25 +0100 Subject: feat: skillshots --- src/shared/imperative.rs | 3 ++- src/shared/projectile.rs | 29 +++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) (limited to 'src/shared') diff --git a/src/shared/imperative.rs b/src/shared/imperative.rs index 256ea1a..61a4762 100644 --- a/src/shared/imperative.rs +++ b/src/shared/imperative.rs @@ -6,7 +6,8 @@ use serde::Serialize; pub enum Imperative { Idle, WalkTo(Vec2), - Attack(AttackKey, PlayerId), + AttackTarget(AttackKey, PlayerId), + AttackDirection(AttackKey, Vec2), } #[derive(Resource, Copy, Clone, PartialEq, Debug, Deserialize, Serialize)] diff --git a/src/shared/projectile.rs b/src/shared/projectile.rs index 16a064a..f944e8a 100644 --- a/src/shared/projectile.rs +++ b/src/shared/projectile.rs @@ -3,17 +3,38 @@ use crate::shared::*; #[derive(Bundle)] pub struct ProjectileBundle { pub projectile: Projectile, - pub position: ProjectilePosition, pub replicate: Replicate, } #[derive(Component, Message, Serialize, Deserialize, Clone, Debug, PartialEq)] + pub struct Projectile { - pub target_player: PlayerId, + pub type_: ProjectileType, pub source_player: PlayerId, pub damage: f32, - pub instant: bool, } #[derive(Component, Message, Serialize, Deserialize, Clone, Debug, PartialEq)] -pub struct ProjectilePosition(pub Vec2); +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, +} -- cgit v1.2.3