~starkingdoms/starkingdoms

ref: 9b91629f33034dab27fe10f953bd39b6477fcac2 starkingdoms/crates/unified/src/ecs.rs -rw-r--r-- 1.6 KiB
9b91629f — core chore(lint): lint/format 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
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 serde::{Deserialize, Serialize};

#[derive(Component, Serialize, Deserialize)]
pub struct Ball;
#[derive(Component, Serialize, Deserialize)]
pub struct Ground;
#[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, Default, Deserialize, Event, Serialize)]
pub struct SendBallHere(pub 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)]
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 {
    pub client: Entity,
}

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