~starkingdoms/starkingdoms

ref: 92b84cca379c046bc49547f68fede1599c9ac3b9 starkingdoms/crates/unified/src/config/planet.rs -rw-r--r-- 1.0 KiB
92b84cca — core fix: dragging 16 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
use bevy::asset::Asset;
use bevy::color::Color;
use crate::prelude::*;
use serde::{Deserialize, Serialize};


#[derive(Deserialize, Asset, TypePath, Component, Serialize, Clone, Debug)]
#[require(
    RigidBody::Static,
    Replicated,
)]
pub struct Planet {
    pub name: String,
    pub sprite: String,
    pub indicator_sprite: Option<String>,
    pub radius: f32,
    pub mass: f32,
    pub default_transform: [f32; 3],
    pub special_sprite_properties: Option<SpecialSpriteProperties>,
    pub orbit: Option<OrbitData>
}

#[derive(Deserialize, TypePath, Serialize, Clone, Debug)]
pub struct OrbitData {
    pub orbiting: String,
    pub eccentricity: f32,
}

#[derive(Deserialize, TypePath, Serialize, Clone, Debug)]
pub enum SpecialSpriteProperties {
    ForceColor(Color),
}

#[derive(Bundle)]
pub struct PlanetBundle {
    pub planet: Planet,
    pub transform: Transform,
    pub collider: Collider,
    pub mass: Mass
}

#[derive(Deserialize, Asset, TypePath)]
pub struct PlanetConfigCollection {
    pub planets: Vec<Planet>,
}