~starkingdoms/starkingdoms

ref: 461d3d233fe9f2f94f9a1f1b9ccf9d1cdc9a9edb starkingdoms/crates/unified/src/ecs.rs -rw-r--r-- 1.8 KiB
461d3d23TerraMaster85 fix starfield alignment(?) 5 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use bevy::ecs::entity::MapEntities;
use bevy::math::Vec2;
use bevy::prelude::{Bundle, Component, Entity, Event, Resource, Transform};
use bevy_rapier2d::dynamics::AdditionalMassProperties;
use bevy_rapier2d::dynamics::RigidBody;
use bevy_rapier2d::geometry::Collider;
use bevy_rapier2d::prelude::*;
use bevy_replicon::prelude::Replicated;
use serde::{Deserialize, Serialize};

#[derive(Component)]
pub struct MainCamera;

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

#[derive(Resource, Default)]
pub struct CursorWorldCoordinates(pub Option<Vec2>);


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

#[derive(Component, Serialize, Deserialize, Debug)]
#[require(ReadMassProperties, RigidBody::Dynamic, ExternalForce, ExternalImpulse, Replicated)]
pub struct Part {
    pub sprite: String,
    pub width: f32,
    pub height: f32,
    pub mass: f32,
}
#[derive(Bundle)]
pub struct PartBundle {
    pub part: Part,
    pub transform: Transform,
    pub collider: Collider,
    pub additional_mass_properties: AdditionalMassProperties,
}

#[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, Event, Debug, MapEntities, Clone)]
pub struct DragRequestEvent(#[entities] pub Entity, pub Vec2);