1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
use crate::protocol::Replicate;
use crate::shared::cooldown::*;
use crate::shared::health::*;
use crate::shared::imperative::*;
use bevy::prelude::*;
use lightyear::prelude::*;
use serde::Deserialize;
use serde::Serialize;
use std::default::Default;
pub mod cooldown;
pub mod health;
pub mod imperative;
pub mod projectile;
pub const KEY: [u8; 32] = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
];
pub const PROTOCOL_ID: u64 = 0;
pub const SERVER_PORT: u16 = 16384;
#[derive(Bundle)]
pub struct PlayerBundle {
id: PlayerId,
position: PlayerPosition,
color: PlayerColor,
replicate: Replicate,
imperative: Imperative,
cooldown: Cooldown,
health: Health,
}
#[derive(Component, Message, Serialize, Deserialize, Clone, Copy, Debug, PartialEq)]
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);
impl PlayerBundle {
pub fn new(id: ClientId, position: Vec2, color: Color) -> Self {
PlayerBundle {
id: PlayerId(id),
position: PlayerPosition(position),
color: PlayerColor(color),
replicate: Replicate::default(),
imperative: Imperative::Idle,
cooldown: Cooldown::default(),
health: Health::default(),
}
}
}
|