server side attack. TODO: fix origin on shooter

This commit is contained in:
2022-08-15 22:46:34 +02:00
parent a8e204e60c
commit 615d9d7080
3 changed files with 40 additions and 36 deletions

View File

@@ -36,7 +36,7 @@ pub struct Jumper {
#[derive(Debug, Serialize, Deserialize, Component)]
pub enum PlayerCommand {
BasicAttack { fired_at: Vec2 },
BasicAttack { origin: Vec2, direction: Vec2 },
}
pub enum ClientChannel {
@@ -60,7 +60,7 @@ pub enum ServerMessages {
},
SpawnProjectile {
entity: Entity,
position: Vec2,
origin: Vec2,
direction: Vec2,
},
DespawnProjectile {
@@ -152,7 +152,7 @@ pub fn setup_level(mut _commands: Commands) {
info!("bygger level...");
}
pub fn spawn_projectile(commands: &mut Commands, location: Vec2, direction: Vec2) -> Entity {
pub fn spawn_projectile(commands: &mut Commands, origin: Vec2, direction: Vec2) -> Entity {
commands
.spawn()
.insert(Collider::ball(0.1))
@@ -160,7 +160,7 @@ pub fn spawn_projectile(commands: &mut Commands, location: Vec2, direction: Vec2
.insert(ActiveEvents::COLLISION_EVENTS)
.insert(Projectile {
duration: Timer::from_seconds(1.5, false),
location,
origin,
direction,
})
.id()
@@ -169,6 +169,6 @@ pub fn spawn_projectile(commands: &mut Commands, location: Vec2, direction: Vec2
#[derive(Debug, Component)]
pub struct Projectile {
pub duration: Timer,
pub location: Vec2,
pub origin: Vec2,
pub direction: Vec2,
}