~starkingdoms/starkingdoms

ref: 3e5cd413bff9de543471151c332b51e657924672 starkingdoms/crates/unified/src/ecs.rs -rw-r--r-- 1.9 KiB
3e5cd413 — core chore: additional debug logging 23 days 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
pub mod thruster;

use crate::config::part::PartConfig;
use bevy::ecs::entity::MapEntities;
use bevy::math::{Quat, Vec2};
use crate::prelude::*;
use bevy_replicon::prelude::Replicated;
use serde::{Deserialize, Serialize};
use avian2d::prelude::*;

#[derive(Component)]
pub struct MainCamera;

#[derive(Component)]
pub struct StarfieldFront;
#[derive(Component)]
pub struct StarfieldMid;
#[derive(Component)]
pub struct StarfieldBack;
#[derive(Component)]
pub struct FuelText;
#[derive(Component)]
pub struct PowerText;

#[derive(Debug, Deserialize, Message, Serialize)]
pub enum ThrustEvent {
    Up(bool),
    Down(bool),
    Left(bool),
    Right(bool),
}

#[derive(Component, Serialize, Deserialize, Debug)]
#[require(
    RigidBody::Dynamic,
    LinearVelocity,
    AngularVelocity,
    ConstantForce,
    Replicated,
)]
pub struct Part {
    pub strong_config: PartConfig,
}
#[derive(Component, Debug)]
pub struct PartHandle(pub Handle<PartConfig>);

#[derive(Component, Serialize, Deserialize, Debug)]
pub struct Player {
    #[entities]
    pub client: Entity,
}

#[derive(Component, Default, Serialize, Deserialize, Debug)]
#[allow(clippy::struct_excessive_bools, reason = "It's not a state machine")]
pub struct PlayerThrust {
    pub up: bool,
    pub down: bool,
    pub left: bool,
    pub right: bool,
}

#[derive(Component, Serialize, Deserialize, Debug)]
pub struct Particles {
    pub effect: String,
    pub active: bool,
}

#[derive(Serialize, Deserialize, Message, Debug, MapEntities, Clone)]
pub struct DragRequestEvent {
    #[entities]
    pub drag_target: Entity,
    pub drag_to: Vec2,
    pub set_rotation: Quat,
    #[entities]
    pub snap_target: Option<Entity>,
    #[entities]
    pub peer_snap: Option<Entity>,
}

#[derive(Component, Serialize, Deserialize, Debug)]
pub struct PlayerStorage {
    pub fuel_capacity: f32,
    pub fuel: f32,
    pub power_capacity: f32,
    pub power: f32,
}

#[derive(Component)]
pub struct Me;