~starkingdoms/starkingdoms

ref: 06663f6e947e1f514a0dd87b4e256ef9de377d17 starkingdoms/crates/unified/src/ecs.rs -rw-r--r-- 3.4 KiB
06663f6e — core feat(netcode-rewrite): remove all networking 30 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
pub mod thruster;

use crate::config::part::PartConfig;
use bevy::math::{Quat, Vec2};
use bevy::camera::visibility::RenderLayers;
use crate::prelude::*;
use avian2d::prelude::*;
use std::collections::HashMap;
use std::sync::LazyLock;

#[derive(States, Debug, Clone, PartialEq, Eq, Hash)]
pub enum GameplayState {
    Main,
    Starguide,
}

pub const MAIN_LAYER: RenderLayers = RenderLayers::layer(0);
pub const STARGUIDE_LAYER: RenderLayers = RenderLayers::layer(1);
pub static MAIN_STAR_LAYERS: LazyLock<RenderLayers> = LazyLock::new(|| RenderLayers::from_layers(&[0, 1]));
pub const ORBIT_LAYER: RenderLayers = RenderLayers::layer(2);

#[derive(Component)]
pub struct MainCamera;
#[derive(Component)]
pub struct StarguideCamera;
#[derive(Component)]
pub struct OrbitCamera;

#[derive(Default, Reflect, GizmoConfigGroup)]
pub struct StarguideGizmos;

#[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(Component)]
pub struct PlanetSensor(pub String); // corresponding planet name

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

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

#[derive(Message, Debug, Clone)]
pub struct DragRequestEvent {
    pub drag_target: Entity,
    pub drag_to: Vec2,
    pub set_rotation: Quat,
    pub snap_target: Option<Entity>,
    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;
#[derive(Component)]
pub struct StarguideMe;

#[derive(Resource)]
pub struct StarguideOrbitImage(pub Handle<Image>);

#[derive(Component)]
pub struct StarguideOrbit;

#[derive(Component, Serialize, Deserialize, Debug)]
pub struct CanCraft;
#[derive(Component, Serialize, Deserialize, Debug)]
pub struct CraftingUi;
#[derive(Message, Debug, Clone)]
pub struct CraftPartRequest {
    pub crafting_part: Entity,
    pub crafted_part: String,
    pub inputs: HashMap<String, u32>,
}

#[derive(Component, Serialize, Deserialize, Debug)]
pub struct Temperature(pub f64);
#[derive(Component, Serialize, Deserialize, Debug)]
pub struct TemperatureSprite;
#[derive(Component, Serialize, Deserialize, Debug)]
pub struct Cooler {
    pub cool_temperature: f64,
    pub heat_cooling_constant: f64,
}
#[derive(Component, Serialize, Deserialize, Debug)]
pub struct Radiator {
    pub emissivity: f64,
    pub surface_area: f64,
}

#[derive(Component, Serialize, Deserialize, Debug)]
pub struct Drill {
    pub drilling: bool,
    pub resource_multiplier: f32,
    pub on_planet: Option<String>,
}
#[derive(Message, Debug, Clone)]
pub struct ToggleDrillEvent {
    pub drill_entity: Entity,
}

#[derive(Component, Serialize, Deserialize, Debug)]
pub struct SingleStorage {
    pub resource_name: String,
    pub capacity: f32,
    pub stored: f32,
}
#[derive(Component, Serialize, Deserialize, Debug)]
pub struct VariableStorage {
    pub resources: HashMap<String, f32>,
    pub capacity: f32,
}