~starkingdoms/starkingdoms

ref: 48c6475b2c83e62ef93be47f4f45fe7a6ae3678c starkingdoms/crates/unified/src/config/planet.rs -rw-r--r-- 821 bytes
48c6475b — ghostly_zsh player input 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
use bevy::asset::Asset;
use bevy::math::Vec3;
use bevy::prelude::{Bundle, Component, Transform, TypePath};
use bevy_rapier2d::prelude::{AdditionalMassProperties, Collider, ReadMassProperties, RigidBody};
use serde::{Deserialize, Serialize};

#[derive(Deserialize, Asset, TypePath, Component, Serialize, Clone, Debug)]
#[require(
    ReadMassProperties,
    RigidBody::Fixed
)]
pub struct Planet {
    pub name: String,
    pub sprite: String,
    pub radius: f32,
    pub mass: f32,
    pub default_transform: [f32; 3]
}

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


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