~starkingdoms/starkingdoms

ref: 4daa8be06437c36f0da4a00a9fc88839fe639b12 starkingdoms/server/src/component.rs -rw-r--r-- 1.6 KiB
4daa8be0 — ghostlyzsh basic organizational fixes 1 year, 4 months ago
                                                                                
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
// StarKingdoms.IO, a browser game about drifting through space
//     Copyright (C) 2023 ghostly_zsh, TerraMaster85, core
//
//     This program is free software: you can redistribute it and/or modify
//     it under the terms of the GNU Affero General Public License as published by
//     the Free Software Foundation, either version 3 of the License, or
//     (at your option) any later version.
//
//     This program is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU Affero General Public License for more details.
//
//     You should have received a copy of the GNU Affero General Public License
//     along with this program.  If not, see <https://www.gnu.org/licenses/>.
use std::net::SocketAddr;

use bevy::prelude::*;
use serde::{Deserialize, Serialize};

use crate::module::component::{Attach, PartBundle};

#[derive(Component, Clone, Copy, Serialize, Deserialize, Debug, Default)]
pub struct Input {
    pub up: bool,
    pub down: bool,
    pub left: bool,
    pub right: bool,
}

#[derive(Component, Clone, Debug)]
pub struct Player {
    pub addr: SocketAddr,
    pub username: String,
    pub input: Input,
    pub selected: Option<Entity>,
    pub save_eligibility: bool,
    pub energy_capacity: u32,
    pub energy: u32,
}


#[derive(Bundle)]
pub struct PlayerBundle {
    pub part: PartBundle,
    pub player: Player,
    pub attach: Attach,
}

#[derive(Resource)]
pub struct AppKeys {
    pub app_key: Vec<u8>,
}